raynstard #3533(2007/10/27 02:59 GMT) [ diff ] Rating0/0=0.00
見直していて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 ) {
Rating0/0=0.00-0+
1 reply [ reply ]
raynstard
#3533()
[
diff
]
Rating0/0=0.00
Rating0/0=0.00-0+