Changeset 24679
- Timestamp:
- 2011-09-28T13:15:12+13:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gs2-extensions/parallel-building/trunk/src/bin/script/GDBMServer.pl
r24666 r24679 168 168 # after your desired function call (like start() below) and the 169 169 # difference in hc_fd gives your new file descriptors in use! [jmt12] 170 #my $openmax = POSIX::sysconf( &POSIX::_SC_OPEN_MAX );171 #$openmax = ( ! defined( $openmax ) || $openmax < 0 ) ? ( shift || 64 ) : $openmax;172 #my $hc_fd = 2;173 #foreach ( 3 .. $openmax )174 #{175 #$hc_fd = $_ if POSIX::close( $_ );176 #}177 #print "[debug] After start fd count = " . $hc_fd . "\n";178 #exit(0);170 #my $openmax = POSIX::sysconf( &POSIX::_SC_OPEN_MAX ); 171 #$openmax = ( ! defined( $openmax ) || $openmax < 0 ) ? ( shift || 64 ) : $openmax; 172 #my $hc_fd = 2; 173 #foreach ( 3 .. $openmax ) 174 #{ 175 # $hc_fd = $_ if POSIX::close( $_ ); 176 #} 177 #print "[debug] After start fd count = " . $hc_fd . "\n"; 178 #exit(0); 179 179 180 180 # @note As mentioned above, I couldn't get the file handles produced by open2 … … 225 225 # these are fd 3, 4, 5, and 6. 226 226 $gdbm = start \@cmd, \$gdbm_writer, \$gdbm_reader; 227 # - start opens four handles! 227 228 228 229 # Daemonize … … 230 231 if (!$no_daemon) 231 232 { 233 # Determine the anonymous array of file descriptors *not* to close 234 my $dont_close_fd = []; 235 # Building upon the "POSIX::Close()" test above, we need to explicitly 236 # determine the new file descriptors opened by the start command. 237 my $openmax = POSIX::sysconf( &POSIX::_SC_OPEN_MAX ); 238 $openmax = ( ! defined( $openmax ) || $openmax < 0 ) ? ( shift || 64 ) : $openmax; 239 # - then figure out the file descriptors currently open. We do this 240 # by attempting to 'copy' each file descriptor. 241 for (my $fd = 3; $fd <= $openmax; $fd++) 242 { 243 #rint "Checking file descriptor: $fd -> "; 244 my $tmpfh; 245 if (open $tmpfh, ">&$fd") 246 { 247 #rint "writable!\n"; 248 push(@{$dont_close_fd}, $fd); 249 close($tmpfh); 250 } 251 elsif (open $tmpfh, "<&$fd") 252 { 253 #rint "readable!\n"; 254 push(@{$dont_close_fd}, $fd); 255 close($tmpfh); 256 } 257 #else 258 #{ 259 # print "not open\n"; 260 #} 261 } 262 print " * When forking don't close these filehandles: [" . join(",", @{$dont_close_fd}) . "]\n"; 263 232 264 print " * Spawning Daemon...\n" unless (!$debug); 233 265 my $daemon_out_path = &util::filename_cat($ENV{'GEXTPARALLELBUILDING'},'logs', 'gdbmserver-' . $infodb_file . '.out'); … … 238 270 # @note as mentioned above, start creates four file descriptors that we need 239 271 # to keep open even through the separation of the daemon process. 240 dont_close_fd => [3,4,5,6]272 dont_close_fd => $dont_close_fd, 241 273 } ); 242 274 } … … 330 362 { 331 363 my $data = shift @_; 364 my $ip = shift @_; 365 my $tid = shift @_; 332 366 my $value = "#ERROR#"; 333 367 # Synchronized debug log writing … … 336 370 lock($debug_log); 337 371 $|++; 338 print " <<" . $data . "\n";372 print "[" . time() . "|" . $tid . "|RECV] " . $data . "\n"; 339 373 $|--; 340 374 } … … 437 471 lock($debug_log); 438 472 $|++; 439 print " >>" . $value . "\n\n";473 print "[" . time() . "|" . $tid . "|SEND] " . $value . "\n\n"; 440 474 $|--; 441 475 }
Note:
See TracChangeset
for help on using the changeset viewer.