Changeset e92c4f4
- Timestamp:
- 2010-07-11T00:29:19Z (14 years ago)
- Branches:
- master
- Children:
- 1e52e1f
- Parents:
- f1c2b21
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ipc.c
rf1c2b21 re92c4f4 171 171 struct bitlbee_child *child = (void*) data; 172 172 char *fwd = NULL; 173 174 /* Normal daemon mode doesn't keep these and has simplified code for 175 takeovers. */ 176 if( child == NULL ) 177 return; 173 178 174 179 if( child->to_child == NULL || … … 359 364 static void ipc_child_cmd_takeover_yes( void *data ) 360 365 { 361 irc_t *irc = data; 366 irc_t *irc = data, *old = NULL; 367 char *to_auth[] = { "TAKEOVER", "AUTH", irc->user->nick, irc->password, NULL }; 362 368 363 369 /* Master->New connection */ … … 365 371 irc->user->nick, irc->password ); 366 372 373 if( global.conf->runmode == RUNMODE_DAEMON ) 374 { 375 GSList *l; 376 377 for( l = irc_connection_list; l; l = l->next ) 378 { 379 old = l->data; 380 381 if( irc != old && 382 irc->user->nick && old->user->nick && 383 irc->password && old->password && 384 strcmp( irc->user->nick, old->user->nick ) == 0 && 385 strcmp( irc->password, old->password ) == 0 ) 386 break; 387 } 388 if( l == NULL ) 389 { 390 to_auth[1] = "FAIL"; 391 ipc_child_cmd_takeover( irc, to_auth ); 392 return; 393 } 394 } 395 367 396 /* Drop credentials, we'll shut down soon and shouldn't overwrite 368 397 any settings. */ 369 398 irc_usermsg( irc, "Trying to take over existing session" ); 399 400 irc_desync( irc ); 401 402 if( old ) 403 { 404 ipc_child_recv_fd = dup( irc->fd ); 405 ipc_child_cmd_takeover( old, to_auth ); 406 } 370 407 371 408 /* TODO: irc_setpass() should do all of this. */ … … 374 411 irc_umode_set( irc, "-R", 1 ); 375 412 376 irc_desync( irc ); 413 if( old ) 414 { 415 irc->status |= USTATUS_SHUTDOWN; 416 irc_abort( irc, FALSE, NULL ); 417 } 377 418 } 378 419 … … 403 444 404 445 ipc_to_master_str( "IDENTIFY %s :%s\r\n", irc->user->nick, irc->password ); 446 447 return TRUE; 448 } 449 else if( global.conf->runmode == RUNMODE_DAEMON ) 450 { 451 GSList *l; 452 irc_t *old; 453 char *to_init[] = { "TAKEOVER", "INIT", NULL }; 454 455 for( l = irc_connection_list; l; l = l->next ) 456 { 457 old = l->data; 458 459 if( irc != old && 460 irc->user->nick && old->user->nick && 461 irc->password && old->password && 462 strcmp( irc->user->nick, old->user->nick ) == 0 && 463 strcmp( irc->password, old->password ) == 0 ) 464 break; 465 } 466 if( l == NULL ) 467 return FALSE; 468 469 ipc_child_cmd_takeover( irc, to_init ); 405 470 406 471 return TRUE; … … 509 574 510 575 *recv_fd = *(int*) CMSG_DATA( cmsg ); 576 /* 511 577 fprintf( stderr, "pid %d received fd %d\n", (int) getpid(), *recv_fd ); 578 */ 512 579 } 513 580 581 /* 514 582 fprintf( stderr, "pid %d received: %s", (int) getpid(), buf ); 583 */ 515 584 return g_strndup( buf, size - 2 ); 516 585 } -
root_commands.c
rf1c2b21 re92c4f4 155 155 irc->status |= USTATUS_IDENTIFIED; 156 156 irc_umode_set( irc, "+R", 1 ); 157 irc_channel_auto_joins( irc, NULL ); 158 159 if( ipc_child_identify( irc ) ) 160 { 161 if( load && set_getbool( &irc->b->set, "auto_connect" ) ) 157 158 /* The following code is a bit hairy now. With takeover 159 support, we shouldn't immediately auto_connect in case 160 we're going to offer taking over an existing session. 161 Do it in 200ms since that should give the parent process 162 enough time to come back to us. */ 163 if( load ) 164 { 165 irc_channel_auto_joins( irc, NULL ); 166 if( set_getbool( &irc->b->set, "auto_connect" ) ) 162 167 irc->login_source_id = b_timeout_add( 200, 163 168 cmd_identify_finish, irc ); 164 169 } 165 else if( load && set_getbool( &irc->b->set, "auto_connect" ) ) 170 171 /* If ipc_child_identify() returns FALSE, it means we're 172 already sure that there's no takeover target (only 173 possible in 1-process daemon mode). Start auto_connect 174 immediately. */ 175 if( !ipc_child_identify( irc ) && load && 176 set_getbool( &irc->b->set, "auto_connect" ) ) 177 { 178 b_event_remove( irc->login_source_id ); 179 irc->login_source_id = -1; 166 180 cmd_identify_finish( irc, 0, 0 ); 181 } 167 182 168 183 break;
Note: See TracChangeset
for help on using the changeset viewer.