- Timestamp:
- 2010-07-11T00:29:19Z (14 years ago)
- Branches:
- master
- Children:
- 1e52e1f
- Parents:
- f1c2b21
- File:
-
- 1 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 }
Note: See TracChangeset
for help on using the changeset viewer.