Comment detail
続・ファイル内の重複行削除 (Nested Flatten)This comment is reply for 3485 raynstard: バッファ固定なのはご愛敬で^^;; 基...(続・ファイル内の重複行削除). Go to thread root.
見直していて94行目がまずいことに気がつきました。 ハッシュテーブルのfdはクローズする前に 使用されていないことが確実でないといけませんね。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | --- doukaku67_2.c 2007-10-27 11:40:13.265625000 +0900
+++ doukaku67.c.usethread 2007-10-27 11:54:29.687500000 +0900
@@ -91,7 +91,12 @@
} else {
if( (table_fd = open(table_name, O_RDWR | O_CREAT, 0600)) == -1 ){ return -1; }
}
- if( fd_history[hist_cursor].fd != -1 ) close( fd_history[hist_cursor].fd );
+ if( fd_history[hist_cursor].fd != -1 )
+ {
+ pthread_mutex_lock( &hash_mutex[ fd_history[hist_cursor].val ] );
+ close( fd_history[hist_cursor].fd );
+ pthread_mutex_unlock( &hash_mutex[ fd_history[hist_cursor].val ] );
+ }
fd_history[hist_cursor].val= hash_value;
fd_history[hist_cursor].fd = table_fd;
hist_cursor++; hist_cursor &= 0x7f;
@@ -162,10 +167,8 @@
/* ハッシュテーブルへ追加 */
hash_value = calcHashValue(ins_item.text, sizeof(ins_item.text));
+ table_fd = history_fd_open(hash_value, 1);
pthread_mutex_lock( &hash_mutex[hash_value] );
- pthread_mutex_lock( &tc.mutex );
- table_fd = history_fd_open(hash_value, 1);
- pthread_mutex_unlock( &tc.mutex );
lseek(table_fd, 0, SEEK_SET); seek = 0;
while( (read_size = read( table_fd, sel_buf, sizeof(sel_buf) ) ) > 0 )
{
|
L:17以降の差分は嘘です。 @@ -162,10 +167,8 @@ 連続投稿申し訳ないです。 オープンはプロセス内で排他制御しないといけないので クローズの時だけ排他制御を追加すれば 問題ないはずでした。 うーん、いろいろ歪みががが
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | --- doukaku67_2.c 2007-10-27 11:40:13.265625000 +0900
+++ doukaku67.c.usethread 2007-10-27 11:54:29.687500000 +0900
@@ -91,7 +91,12 @@
} else {
if( (table_fd = open(table_name, O_RDWR | O_CREAT, 0600)) == -1 ){ return -1; }
}
- if( fd_history[hist_cursor].fd != -1 ) close( fd_history[hist_cursor].fd );
+ if( fd_history[hist_cursor].fd != -1 )
+ {
+ pthread_mutex_lock( &hash_mutex[ fd_history[hist_cursor].val ] );
+ close( fd_history[hist_cursor].fd );
+ pthread_mutex_unlock( &hash_mutex[ fd_history[hist_cursor].val ] );
+ }
fd_history[hist_cursor].val= hash_value;
fd_history[hist_cursor].fd = table_fd;
hist_cursor++; hist_cursor &= 0x7f;
|




raynstard
#3532()
[
C
]
Rating0/0=0.00
Rating0/0=0.00-0+