* AbstractCommand.cc: casted timeout value to long long int.

* ChunkedEncoding.cc: fixed memory leak.
	* PeerInteractionCommand.cc: casted timeout value to long long 
int.
	* SleepCommand.cc: casted timeout value to long long int.
	* Data.cc: fixed memory leak.
	* Data.cc: fixed toLLInt().
	* BitfieldMan.cc: fixed memory leak.
	* TorrentMan.cc: initialized storeDir to ".".
	* TorrentMan.cc: fixed memory leak.
	* TorrentMan.cc: corrected file paths of splitted files.
	* PeerAbstractCommand.cc: casted timeout to long long int.
	* main.cc: added delete(req) and delete(te->diskWriter).
	* RequestSlot.cc: casted timeout value to long long int.
	* Request.cc: fixed memory leak.
	* PendingMessage.cc: make HAVE messages sent only when peer does 
not
	have the piece.
	* Peer.{h,cc}: added hasPiece(int index).
pull/1/head
Tatsuhiro Tsujikawa 2006-03-23 10:47:25 +00:00
parent 198b87fa3e
commit 1fcd640d3b
18 changed files with 168 additions and 160 deletions

View File

@ -12,6 +12,23 @@
to Constructor. Also, moved digest cleanup to Destructor.
* MetaFileUtil.cc: fixed memory leak
* replaced std::vector with std::deque.
* AbstractCommand.cc: casted timeout value to long long int.
* ChunkedEncoding.cc: fixed memory leak.
* PeerInteractionCommand.cc: casted timeout value to long long int.
* SleepCommand.cc: casted timeout value to long long int.
* Data.cc: fixed memory leak.
* Data.cc: fixed toLLInt().
* BitfieldMan.cc: fixed memory leak.
* TorrentMan.cc: initialized storeDir to ".".
* TorrentMan.cc: fixed memory leak.
* TorrentMan.cc: corrected file paths of splitted files.
* PeerAbstractCommand.cc: casted timeout to long long int.
* main.cc: added delete(req) and delete(te->diskWriter).
* RequestSlot.cc: casted timeout value to long long int.
* Request.cc: fixed memory leak.
* PendingMessage.cc: make HAVE messages sent only when peer does not
have the piece.
* Peer.{h,cc}: added hasPiece(int index).
2006-03-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
"POT-Creation-Date: 2006-03-22 00:47+0900\n"
"POT-Creation-Date: 2006-03-23 19:46+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -177,35 +177,35 @@ msgstr ""
msgid "Got EOF from the server."
msgstr ""
#: src/main.cc:58
#: src/main.cc:60
#, c-format
msgid ""
"\n"
"The download was complete. <%s>\n"
msgstr ""
#: src/main.cc:62
#: src/main.cc:64
msgid ""
"\n"
"The download was not complete because of errors. Check the log.\n"
msgstr ""
#: src/main.cc:73 src/main.cc:82
#: src/main.cc:75 src/main.cc:84
msgid ""
"\n"
"SIGINT signal received."
msgstr ""
#: src/main.cc:104
#: src/main.cc:106
#, c-format
msgid "Unrecognized URL or unsupported protocol: %s\n"
msgstr ""
#: src/main.cc:110
#: src/main.cc:112
msgid " version "
msgstr ""
#: src/main.cc:114
#: src/main.cc:116
msgid ""
"This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
@ -222,40 +222,40 @@ msgid ""
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n"
msgstr ""
#: src/main.cc:128
#: src/main.cc:130
#, c-format
msgid "Contact Info: %s\n"
msgstr ""
#: src/main.cc:134
#: src/main.cc:136
#, c-format
msgid "Usage: %s [options] URL ...\n"
msgstr ""
#: src/main.cc:136
#: src/main.cc:138
msgid "Options:"
msgstr ""
#: src/main.cc:137
#: src/main.cc:139
msgid " -d, --dir=DIR The directory to store downloaded file."
msgstr ""
#: src/main.cc:138
#: src/main.cc:140
msgid " -o, --out=FILE The file name for downloaded file."
msgstr ""
#: src/main.cc:139
#: src/main.cc:141
msgid ""
" -l, --log=LOG The file path to store log. If '-' is "
"specified,\n"
" log is written to stdout."
msgstr ""
#: src/main.cc:141
#: src/main.cc:143
msgid " -D, --daemon Run as daemon."
msgstr ""
#: src/main.cc:142
#: src/main.cc:144
msgid ""
" -s, --split=N Download a file using N connections. N must "
"be\n"
@ -265,24 +265,24 @@ msgid ""
" N connections."
msgstr ""
#: src/main.cc:146
#: src/main.cc:148
msgid ""
" --retry-wait=SEC Set amount of time in second between requests\n"
" for errors. Specify a value between 0 and 60.\n"
" Default: 5"
msgstr ""
#: src/main.cc:149
#: src/main.cc:151
msgid " -t, --timeout=SEC Set timeout in second. Default: 60"
msgstr ""
#: src/main.cc:150
#: src/main.cc:152
msgid ""
" -m, --max-tries=N Set number of tries. 0 means unlimited.\n"
" Default: 5"
msgstr ""
#: src/main.cc:152
#: src/main.cc:154
msgid ""
" --min-segment-size=SIZE[K|M] Set minimum segment size. You can append\n"
" K or M(1K = 1024, 1M = 1024K). This\n"
@ -290,40 +290,40 @@ msgid ""
" 1024."
msgstr ""
#: src/main.cc:156
#: src/main.cc:158
msgid ""
" --http-proxy=HOST:PORT Use HTTP proxy server. This affects to all\n"
" URLs."
msgstr ""
#: src/main.cc:158
#: src/main.cc:160
msgid " --http-user=USER Set HTTP user. This affects to all URLs."
msgstr ""
#: src/main.cc:159
#: src/main.cc:161
msgid ""
" --http-passwd=PASSWD Set HTTP password. This affects to all URLs."
msgstr ""
#: src/main.cc:160
#: src/main.cc:162
msgid ""
" --http-proxy-user=USER Set HTTP proxy user. This affects to all URLs"
msgstr ""
#: src/main.cc:161
#: src/main.cc:163
msgid ""
" --http-proxy-passwd=PASSWD Set HTTP proxy password. This affects to all "
"URLs."
msgstr ""
#: src/main.cc:162
#: src/main.cc:164
msgid ""
" --http-proxy-method=METHOD Set the method to use in proxy request.\n"
" METHOD is either 'get' or 'tunnel'.\n"
" Default: tunnel"
msgstr ""
#: src/main.cc:165
#: src/main.cc:167
msgid ""
" --http-auth-scheme=SCHEME Set HTTP authentication scheme. Currently, "
"basic\n"
@ -334,23 +334,23 @@ msgid ""
" as well as --http-user and --http-passwd."
msgstr ""
#: src/main.cc:169
#: src/main.cc:171
msgid " --referer=REFERER Set Referer. This affects to all URLs."
msgstr ""
#: src/main.cc:170
#: src/main.cc:172
msgid ""
" --ftp-user=USER Set FTP user. This affects to all URLs.\n"
" Default: anonymous"
msgstr ""
#: src/main.cc:172
#: src/main.cc:174
msgid ""
" --ftp-passwd=PASSWD Set FTP password. This affects to all URLs.\n"
" Default: ARIA2USER@"
msgstr ""
#: src/main.cc:174
#: src/main.cc:176
msgid ""
" --ftp-type=TYPE Set FTP transfer type. TYPE is either "
"'binary'\n"
@ -358,11 +358,11 @@ msgid ""
" Default: binary"
msgstr ""
#: src/main.cc:177
#: src/main.cc:179
msgid " -p, --ftp-pasv Use passive mode in FTP."
msgstr ""
#: src/main.cc:178
#: src/main.cc:180
msgid ""
" --ftp-via-http-proxy=METHOD Use HTTP proxy in FTP. METHOD is either 'get' "
"or\n"
@ -370,11 +370,11 @@ msgid ""
" Default: tunnel"
msgstr ""
#: src/main.cc:182
#: src/main.cc:184
msgid " --torrent-file=TORRENT_FILE The file path to .torrent file."
msgstr ""
#: src/main.cc:183
#: src/main.cc:185
msgid ""
" --follow-torrent=true|false Setting this option to false prevents aria2 "
"to\n"
@ -383,97 +383,97 @@ msgid ""
" Default: true"
msgstr ""
#: src/main.cc:188
#: src/main.cc:190
msgid " -v, --version Print the version number and exit."
msgstr ""
#: src/main.cc:189
#: src/main.cc:191
msgid " -h, --help Print this message and exit."
msgstr ""
#: src/main.cc:192
#: src/main.cc:194
msgid ""
" You can specify multiple URLs. All URLs must point to the same file\n"
" or downloading fails."
msgstr ""
#: src/main.cc:195
#: src/main.cc:197
msgid "Examples:"
msgstr ""
#: src/main.cc:196
#: src/main.cc:198
msgid " Download a file by 1 connection:"
msgstr ""
#: src/main.cc:198
#: src/main.cc:200
msgid " Download a file by 2 connections:"
msgstr ""
#: src/main.cc:200
#: src/main.cc:202
msgid " Download a file by 2 connections, each connects to a different server:"
msgstr ""
#: src/main.cc:202
#: src/main.cc:204
msgid " You can mix up different protocols:"
msgstr ""
#: src/main.cc:205
#: src/main.cc:207
msgid " Download a torrent:"
msgstr ""
#: src/main.cc:207
#: src/main.cc:209
msgid " Download a torrent using local .torrent file:"
msgstr ""
#: src/main.cc:211
#: src/main.cc:213
#, c-format
msgid "Reports bugs to %s"
msgstr ""
#: src/main.cc:296
#: src/main.cc:298
msgid "unrecognized proxy format"
msgstr ""
#: src/main.cc:322
#: src/main.cc:324
msgid "Currently, supported authentication scheme is basic."
msgstr ""
#: src/main.cc:331
#: src/main.cc:333
msgid "retry-wait must be between 0 and 60."
msgstr ""
#: src/main.cc:348
#: src/main.cc:350
msgid "ftp-type must be either 'binary' or 'ascii'."
msgstr ""
#: src/main.cc:357
#: src/main.cc:359
msgid "ftp-via-http-proxy must be either 'get' or 'tunnel'."
msgstr ""
#: src/main.cc:375
#: src/main.cc:377
msgid "min-segment-size invalid"
msgstr ""
#: src/main.cc:386
#: src/main.cc:388
msgid "http-proxy-method must be either 'get' or 'tunnel'."
msgstr ""
#: src/main.cc:400
#: src/main.cc:402
msgid "follow-torrent must be either 'true' or 'false'."
msgstr ""
#: src/main.cc:426
#: src/main.cc:428
msgid "split must be between 1 and 5."
msgstr ""
#: src/main.cc:436
#: src/main.cc:438
msgid "timeout must be between 1 and 600"
msgstr ""
#: src/main.cc:445
#: src/main.cc:447
msgid "max-tries invalid"
msgstr ""
#: src/main.cc:468
#: src/main.cc:470
msgid "specify at least one URL"
msgstr ""

BIN
po/ja.gmo

Binary file not shown.

114
po/ja.po
View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: aria2c 0.2.1\n"
"Report-Msgid-Bugs-To: http://aria2.sourceforge.net/\n"
"POT-Creation-Date: 2006-03-22 00:47+0900\n"
"POT-Creation-Date: 2006-03-23 19:46+0900\n"
"PO-Revision-Date: 2006-03-22 00:48+0900\n"
"Last-Translator: Tatsuhiro Tsujikawa <tujikawa@rednoah.com>\n"
"Language-Team: Japanese <ja@li.org>\n"
@ -185,7 +185,7 @@ msgstr "
msgid "Got EOF from the server."
msgstr "サーバーから EOF を受けとりました."
#: src/main.cc:58
#: src/main.cc:60
#, c-format
msgid ""
"\n"
@ -194,7 +194,7 @@ msgstr ""
"\n"
"<%s> のダウンロードが完了しました.\n"
#: src/main.cc:62
#: src/main.cc:64
msgid ""
"\n"
"The download was not complete because of errors. Check the log.\n"
@ -202,7 +202,7 @@ msgstr ""
"\n"
"ダウンロードはエラーのため完了していません. ログを確認してください.\n"
#: src/main.cc:73 src/main.cc:82
#: src/main.cc:75 src/main.cc:84
msgid ""
"\n"
"SIGINT signal received."
@ -210,18 +210,18 @@ msgstr ""
"\n"
"SIGINT シグナルを受け取りました."
#: src/main.cc:104
#: src/main.cc:106
#, c-format
msgid "Unrecognized URL or unsupported protocol: %s\n"
msgstr ""
"%s は, 理解できない URL フォーマット, または, サポートされないプロトコルで"
"す.\n"
#: src/main.cc:110
#: src/main.cc:112
msgid " version "
msgstr " バージョン "
#: src/main.cc:114
#: src/main.cc:116
msgid ""
"This program is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
@ -252,31 +252,31 @@ msgstr ""
"Temple Place, Suite 330, Boston, MA 02111-1307 USA)。\n"
"(訳: http://www.opensource.jp/gpl/gpl.ja.html.euc-jp)\n"
#: src/main.cc:128
#: src/main.cc:130
#, c-format
msgid "Contact Info: %s\n"
msgstr "連絡先: %s\n"
#: src/main.cc:134
#: src/main.cc:136
#, c-format
msgid "Usage: %s [options] URL ...\n"
msgstr "使い方: %s [オプション] URL ...\n"
#: src/main.cc:136
#: src/main.cc:138
msgid "Options:"
msgstr "オプション:"
#: src/main.cc:137
#: src/main.cc:139
msgid " -d, --dir=DIR The directory to store downloaded file."
msgstr ""
" -d, --dir=DIR ダウンロードしたファイルを保存するディレクトリ."
#: src/main.cc:138
#: src/main.cc:140
msgid " -o, --out=FILE The file name for downloaded file."
msgstr ""
" -o, --out=FILE ダウンロードしたファイルの保存先ファイル名."
#: src/main.cc:139
#: src/main.cc:141
msgid ""
" -l, --log=LOG The file path to store log. If '-' is "
"specified,\n"
@ -286,11 +286,11 @@ msgstr ""
"力\n"
" に出力します."
#: src/main.cc:141
#: src/main.cc:143
msgid " -D, --daemon Run as daemon."
msgstr " -D, --daemon デーモンとして起動します."
#: src/main.cc:142
#: src/main.cc:144
msgid ""
" -s, --split=N Download a file using N connections. N must "
"be\n"
@ -309,7 +309,7 @@ msgstr ""
"ショ\n"
" ンを確立します."
#: src/main.cc:146
#: src/main.cc:148
msgid ""
" --retry-wait=SEC Set amount of time in second between requests\n"
" for errors. Specify a value between 0 and 60.\n"
@ -320,13 +320,13 @@ msgstr ""
" す. 0 - 60 の値を指定してください.\n"
" デフォルト値: 5"
#: src/main.cc:149
#: src/main.cc:151
msgid " -t, --timeout=SEC Set timeout in second. Default: 60"
msgstr ""
" -t, --timeout=SEC タイムアウトとなる時間を秒で指定します.\n"
" デフォルト値: 60"
#: src/main.cc:150
#: src/main.cc:152
msgid ""
" -m, --max-tries=N Set number of tries. 0 means unlimited.\n"
" Default: 5"
@ -335,7 +335,7 @@ msgstr ""
"行\n"
" します. デフォルト値: 5"
#: src/main.cc:152
#: src/main.cc:154
msgid ""
" --min-segment-size=SIZE[K|M] Set minimum segment size. You can append\n"
" K or M(1K = 1024, 1M = 1024K). This\n"
@ -348,7 +348,7 @@ msgstr ""
"1024K).\n"
" 1024 以上の値を指定してください."
#: src/main.cc:156
#: src/main.cc:158
msgid ""
" --http-proxy=HOST:PORT Use HTTP proxy server. This affects to all\n"
" URLs."
@ -357,14 +357,14 @@ msgstr ""
"シ\n"
" ョンはすべての URL に影響します."
#: src/main.cc:158
#: src/main.cc:160
msgid " --http-user=USER Set HTTP user. This affects to all URLs."
msgstr ""
" --http-user=USER HTTP での認証ユーザーを指定します. このオプショ"
"ン\n"
" はすべての URL に影響します."
#: src/main.cc:159
#: src/main.cc:161
msgid ""
" --http-passwd=PASSWD Set HTTP password. This affects to all URLs."
msgstr ""
@ -372,7 +372,7 @@ msgstr ""
"ショ\n"
" ンはすべての URL に影響します."
#: src/main.cc:160
#: src/main.cc:162
msgid ""
" --http-proxy-user=USER Set HTTP proxy user. This affects to all URLs"
msgstr ""
@ -382,7 +382,7 @@ msgstr ""
"ま\n"
" す."
#: src/main.cc:161
#: src/main.cc:163
msgid ""
" --http-proxy-passwd=PASSWD Set HTTP proxy password. This affects to all "
"URLs."
@ -393,7 +393,7 @@ msgstr ""
"し\n"
" ます."
#: src/main.cc:162
#: src/main.cc:164
msgid ""
" --http-proxy-method=METHOD Set the method to use in proxy request.\n"
" METHOD is either 'get' or 'tunnel'.\n"
@ -404,7 +404,7 @@ msgstr ""
" す. 'get' または 'tunnel' を指定してください.\n"
" デフォルト値: tunnel"
#: src/main.cc:165
#: src/main.cc:167
msgid ""
" --http-auth-scheme=SCHEME Set HTTP authentication scheme. Currently, "
"basic\n"
@ -422,14 +422,14 @@ msgstr ""
"定\n"
" する必要があります."
#: src/main.cc:169
#: src/main.cc:171
msgid " --referer=REFERER Set Referer. This affects to all URLs."
msgstr ""
" --referer=REFERER リファラーを指定します. このオプションはすべて"
"の\n"
" URL に影響します."
#: src/main.cc:170
#: src/main.cc:172
msgid ""
" --ftp-user=USER Set FTP user. This affects to all URLs.\n"
" Default: anonymous"
@ -439,7 +439,7 @@ msgstr ""
" はすべての URL に影響します.\n"
" デフォルト値: anonymous"
#: src/main.cc:172
#: src/main.cc:174
msgid ""
" --ftp-passwd=PASSWD Set FTP password. This affects to all URLs.\n"
" Default: ARIA2USER@"
@ -449,7 +449,7 @@ msgstr ""
" ンはすべての URL に影響します.\n"
" デフォルト値: ARIA2USER@"
#: src/main.cc:174
#: src/main.cc:176
msgid ""
" --ftp-type=TYPE Set FTP transfer type. TYPE is either "
"'binary'\n"
@ -460,11 +460,11 @@ msgstr ""
" 'ascii' を指定してください. デフォルト値: "
"binary"
#: src/main.cc:177
#: src/main.cc:179
msgid " -p, --ftp-pasv Use passive mode in FTP."
msgstr " -p, --ftp-pasv FTP で passive モードを使用します."
#: src/main.cc:178
#: src/main.cc:180
msgid ""
" --ftp-via-http-proxy=METHOD Use HTTP proxy in FTP. METHOD is either 'get' "
"or\n"
@ -477,11 +477,11 @@ msgstr ""
"く\n"
" ださい. デフォルト値: tunnel"
#: src/main.cc:182
#: src/main.cc:184
msgid " --torrent-file=TORRENT_FILE The file path to .torrent file."
msgstr " --torrent-file=TORRENT_FILE .torrent ファイルのパスを指定."
#: src/main.cc:183
#: src/main.cc:185
msgid ""
" --follow-torrent=true|false Setting this option to false prevents aria2 "
"to\n"
@ -496,16 +496,16 @@ msgstr ""
" は, BitTorrent モードに入りません.\n"
" デフォルト値: true"
#: src/main.cc:188
#: src/main.cc:190
msgid " -v, --version Print the version number and exit."
msgstr " -v, --version バージョン番号を表示し, 終了します."
#: src/main.cc:189
#: src/main.cc:191
msgid " -h, --help Print this message and exit."
msgstr ""
" -h, --help このヘルプメッセージを表示し, 終了します."
#: src/main.cc:192
#: src/main.cc:194
msgid ""
" You can specify multiple URLs. All URLs must point to the same file\n"
" or downloading fails."
@ -514,83 +514,83 @@ msgstr ""
"れ\n"
" ばなりません. さもなくばダウンロードは失敗します."
#: src/main.cc:195
#: src/main.cc:197
msgid "Examples:"
msgstr "例:"
#: src/main.cc:196
#: src/main.cc:198
msgid " Download a file by 1 connection:"
msgstr " 1 コネクションでのダウンロード:"
#: src/main.cc:198
#: src/main.cc:200
msgid " Download a file by 2 connections:"
msgstr " 2 コネクションでのダウンロード:"
#: src/main.cc:200
#: src/main.cc:202
msgid " Download a file by 2 connections, each connects to a different server:"
msgstr " 二つの異なるサーバーに接続してダウンロード:"
#: src/main.cc:202
#: src/main.cc:204
msgid " You can mix up different protocols:"
msgstr " 異なるプロトコルを混合させてダウンロード:"
#: src/main.cc:205
#: src/main.cc:207
msgid " Download a torrent:"
msgstr "torrent をダウンロード:"
#: src/main.cc:207
#: src/main.cc:209
msgid " Download a torrent using local .torrent file:"
msgstr " ローカル .torrent ファイルを使ってダウンロード:"
#: src/main.cc:211
#: src/main.cc:213
#, c-format
msgid "Reports bugs to %s"
msgstr "バグレポートはこちらへ: %s"
#: src/main.cc:296
#: src/main.cc:298
msgid "unrecognized proxy format"
msgstr "理解できないProxyフォーマットです."
#: src/main.cc:322
#: src/main.cc:324
msgid "Currently, supported authentication scheme is basic."
msgstr "現在サポートされている認証方法は basic です."
#: src/main.cc:331
#: src/main.cc:333
msgid "retry-wait must be between 0 and 60."
msgstr "retry-wait は 0 から 60 の間で指定してください."
#: src/main.cc:348
#: src/main.cc:350
msgid "ftp-type must be either 'binary' or 'ascii'."
msgstr "ftp-type は 'binary' または 'ascii' を指定してください."
#: src/main.cc:357
#: src/main.cc:359
msgid "ftp-via-http-proxy must be either 'get' or 'tunnel'."
msgstr "ftp-via-http-proxy は 'get' または 'tunnel' を指定してください."
#: src/main.cc:375
#: src/main.cc:377
msgid "min-segment-size invalid"
msgstr "min-segment-size が不正です."
#: src/main.cc:386
#: src/main.cc:388
msgid "http-proxy-method must be either 'get' or 'tunnel'."
msgstr "http-proxy-method は 'get' または 'tunnel' を指定してください."
#: src/main.cc:400
#: src/main.cc:402
msgid "follow-torrent must be either 'true' or 'false'."
msgstr "follow-torrent は 'true' または 'false を指定してください."
#: src/main.cc:426
#: src/main.cc:428
msgid "split must be between 1 and 5."
msgstr "split は 1 - 5 の値を指定してください."
#: src/main.cc:436
#: src/main.cc:438
msgid "timeout must be between 1 and 600"
msgstr "timeout は 1 - 600 の値を指定してください."
#: src/main.cc:445
#: src/main.cc:447
msgid "max-tries invalid"
msgstr "max-tries が不正です."
#: src/main.cc:468
#: src/main.cc:470
msgid "specify at least one URL"
msgstr "一個以上の URL を指定してください."

View File

@ -62,7 +62,7 @@ bool AbstractCommand::isTimeoutDetected() {
return false;
} else {
long long int elapsed = Util::difftv(now, checkPoint);
if(elapsed >= e->option->getAsInt(PREF_TIMEOUT)*1000000) {
if(elapsed >= e->option->getAsLLInt(PREF_TIMEOUT)*1000000) {
return true;
} else {
return false;

View File

@ -111,6 +111,7 @@ int BitfieldMan::getMissingIndex(const unsigned char* peerBitfield, int length)
}
int max = countSetBit(tempBitfield, bitfieldLength);
int index = getMissingIndexRandomly(tempBitfield, bitfieldLength, max);
delete [] tempBitfield;
return index;
}
@ -123,36 +124,8 @@ int BitfieldMan::getMissingUnusedIndex(const unsigned char* peerBitfield, int le
tempBitfield[i] = peerBitfield[i] & ~bitfield[i] & ~useBitfield[i];
}
int max = countSetBit(tempBitfield, bitfieldLength);
/*
int max = 0;
for(int i = 0; i < bitfieldLength; i++) {
unsigned char bit = tempBitfield[i];
for(int bs = 7; bs >= 0 && i*8+7-bs < blocks; bs--) {
unsigned char mask = 1 << bs;
if(bit & mask) {
max++;
}
}
}
*/
int index = getMissingIndexRandomly(tempBitfield, bitfieldLength, max);
/*
int index = -1;
int nth = 1+(int)(((double)max)*random()/(RAND_MAX+1.0));
for(int i = 0; i < bitfieldLength && index == -1; i++) {
unsigned char bit = tempBitfield[i];
for(int bs = 7; bs >= 0 && i*8+7-bs < blocks; bs--) {
unsigned char mask = 1 << bs;
if(bit & mask) {
nth--;
if(nth == 0) {
index = i*8+7-bs;
break;
}
}
}
}
*/
delete [] tempBitfield;
return index;
}

View File

@ -154,6 +154,7 @@ int ChunkedEncoding::readChunkSize(char** pp) {
temp[exsp-*pp] = '\0';
chunkSize = strtol(temp, NULL, 16);
delete [] temp;
if(chunkSize < 0) {
throw new DlAbortEx(EX_INVALID_CHUNK_SIZE);
} else if(errno == ERANGE && (chunkSize == LONG_MAX || chunkSize == LONG_MIN)) {

View File

@ -44,7 +44,9 @@ string Data::toString() const {
char* temp = new char[len+1];
memcpy(temp, data, len);
temp[len] = '\0';
return string(temp);
string str(temp);
delete [] temp;
return str;
}
}
@ -68,7 +70,7 @@ long long int Data::toLLInt() const {
if(len == 0) {
return 0;
} else {
return strtoll(data, NULL, 10);
return strtoll(toString().c_str(), NULL, 10);
}
}

View File

@ -46,3 +46,7 @@ bool Peer::shouldChoke() const {
return peerDownload >= peerUpload+pieceLength*4;
}
}
bool Peer::hasPiece(int index) const {
return bitfield->isBitSet(index);
}

View File

@ -109,6 +109,8 @@ public:
bool shouldChoke() const;
bool hasPiece(int index) const;
static Peer* nullPeer;
};

View File

@ -63,7 +63,7 @@ bool PeerAbstractCommand::isTimeoutDetected() {
return false;
} else {
long long int elapsed = Util::difftv(now, checkPoint);
if(elapsed >= e->option->getAsInt(PREF_TIMEOUT)*1000000) {
if(elapsed >= e->option->getAsLLInt(PREF_TIMEOUT)*1000000) {
return true;
} else {
return false;

View File

@ -361,7 +361,7 @@ void PeerInteractionCommand::keepAlive() {
} else {
struct timeval now;
gettimeofday(&now, NULL);
if(Util::difftv(now, keepAliveCheckPoint) >= 120*1000000) {
if(Util::difftv(now, keepAliveCheckPoint) >= (long long int)120*1000000) {
if(pendingMessages.empty()) {
peerConnection->sendKeepAlive();
}

View File

@ -25,7 +25,9 @@ bool PendingMessage::processMessage() {
bool retval = true;
switch(peerMessageId) {
case PeerMessage::HAVE:
peerConnection->sendHave(index);
if(!peerConnection->getPeer()->hasPiece(index)) {
peerConnection->sendHave(index);
}
break;
case PeerMessage::BITFIELD:
peerConnection->sendBitfield();

View File

@ -36,7 +36,9 @@ Request::Request():port(0), tryCount(0), isTorrent(false) {
cookieBox = new CookieBox();
}
Request::~Request() {}
Request::~Request() {
delete cookieBox;
}
bool Request::setUrl(string url) {
this->url = url;

View File

@ -55,7 +55,7 @@ void RequestSlot::setDispatchedTime() {
bool RequestSlot::isTimeout(int timeoutSec) const {
struct timeval now;
gettimeofday(&now, NULL);
return Util::difftv(now, dispatchedTime) > timeoutSec*1000000;
return Util::difftv(now, dispatchedTime) > ((long long int)timeoutSec)*1000000;
}
bool RequestSlot::isNull(const RequestSlot& requestSlot) {

View File

@ -36,7 +36,7 @@ SleepCommand::~SleepCommand() {
bool SleepCommand::execute() {
struct timeval now;
gettimeofday(&now, NULL);
if(Util::difftv(now, checkPoint) >= wait*1000000) {
if(Util::difftv(now, checkPoint) >= ((long long int)wait)*1000000) {
engine->commands.push(nextCommand);
nextCommand = NULL;
return true;

View File

@ -37,11 +37,12 @@ TorrentMan::TorrentMan():bitfield(NULL),
peerEntryIdCounter(0), cuidCounter(0),
downloadedSize(0), uploadedSize(0),
deltaDownload(0), deltaUpload(0),
storeDir("."),
multiFileTopDir(NULL),
interval(DEFAULT_ANNOUNCE_INTERVAL),
minInterval(DEFAULT_ANNOUNCE_MIN_INTERVAL),
complete(0), incomplete(0),
connections(0) {}
connections(0), diskWriter(NULL) {}
TorrentMan::~TorrentMan() {
if(bitfield != NULL) {
@ -53,6 +54,9 @@ TorrentMan::~TorrentMan() {
for(Peers::iterator itr = peers.begin(); itr != peers.end(); itr++) {
delete *itr;
}
if(diskWriter != NULL) {
delete diskWriter;
}
}
// TODO do not use this method in application code
@ -316,7 +320,6 @@ void TorrentMan::setup(string metaInfoFile) {
name = string(basename(basec))+".file";
free(basec);
}
List* files = (List*)infoDic->get("files");
if(files == NULL) {
// single-file mode;
@ -356,7 +359,6 @@ void TorrentMan::setup(string metaInfoFile) {
announce = ((Data*)topDic->get("announce"))->toString();
pieceLength = ((Data*)infoDic->get("piece length"))->toInt();
pieces = totalSize/pieceLength+(totalSize%pieceLength ? 1 : 0);
Data* piecesHashData = (Data*)infoDic->get("pieces");
if(piecesHashData->getLen() != pieces*20) {
throw new DlAbortEx("the number of pieces is wrong.");
@ -388,7 +390,7 @@ string TorrentMan::getPieceHash(int index) const {
}
string TorrentMan::getFilePath() const {
return (storeDir == "" ? "." : storeDir)+"/"+name;
return storeDir+"/"+name;
}
string TorrentMan::getTempFilePath() const {
@ -499,11 +501,13 @@ void TorrentMan::renameSingleFile() const {
}
void TorrentMan::splitMultiFile() const {
multiFileTopDir->createDir((storeDir == "" ? "." : storeDir), true);
logger->info("creating directories");
multiFileTopDir->createDir(storeDir, true);
long long int offset = 0;
logger->info("splitting file");
for(MultiFileEntries::const_iterator itr = multiFileEntries.begin();
itr != multiFileEntries.end(); itr++) {
Util::rangedFileCopy(itr->path, getTempFilePath(), offset, itr->length);
Util::rangedFileCopy(storeDir+"/"+itr->path, getTempFilePath(), offset, itr->length);
offset += itr->length;
}
unlink(getTempFilePath().c_str());

View File

@ -525,7 +525,7 @@ int main(int argc, char* argv[]) {
Requests requests;
for(int i = 1; optind+i-1 < argc; i++) {
for(int s = 1; s <= split; s++) {
addCommand(split*(i-1)+s, argv[optind+i-1], referer, requests);
addCommand(split*(i-1)+s, argv[optind+i-1], referer, requests);
}
}
e->run();
@ -594,9 +594,10 @@ int main(int argc, char* argv[]) {
} else {
printDownloadAbortMessage();
}
delete(req);
delete(te->segmentMan);
delete(te->torrentMan);
delete(te->diskWriter);
delete(te);
} catch(Exception* ex) {
cerr << ex->getMsg() << endl;