Changeset 8a56e52 for ipc.c


Ignore:
Timestamp:
2006-03-01T22:30:10Z (14 years ago)
Author:
Jelmer Vernooij <jelmer@…>
Branches:
master
Children:
5fe0207
Parents:
6dff9d4
Message:

Improve error handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ipc.c

    r6dff9d4 r8a56e52  
    469469
    470470        child->ipc_fd = accept(serversock, NULL, 0);
     471
     472        if (child->ipc_fd == -1) {
     473                log_message( LOGLVL_WARNING, "Unable to accept connection on UNIX domain socket: %s", strerror(errno) );
     474                return TRUE;
     475        }
    471476               
    472477        child->ipc_inpa = gaim_input_add( child->ipc_fd, GAIM_INPUT_READ, ipc_master_read, child );
     
    485490
    486491        /* Clean up old socket files that were hanging around.. */
    487         unlink(IPCSOCKET);
     492        if (unlink(IPCSOCKET) == -1 && errno != ENOENT) {
     493                log_message( LOGLVL_ERROR, "Could not remove old IPC socket at %s: %s", IPCSOCKET, strerror(errno) );
     494                return 0;
     495        }
    488496
    489497        un_addr.sun_family = AF_UNIX;
     
    492500        serversock = socket(AF_UNIX, SOCK_STREAM, PF_UNIX);
    493501
    494         bind(serversock, &un_addr, sizeof(un_addr));
    495 
    496         listen(serversock, 5);
     502        if (serversock == -1) {
     503                log_message( LOGLVL_WARNING, "Unable to create UNIX socket: %s", strerror(errno) );
     504                return 0;
     505        }
     506
     507        if (bind(serversock, &un_addr, sizeof(un_addr)) == -1) {
     508                log_message( LOGLVL_WARNING, "Unable to bind UNIX socket to %s: %s", IPCSOCKET, strerror(errno) );
     509                return 0;
     510        }
     511
     512        if (listen(serversock, 5) == -1) {
     513                log_message( LOGLVL_WARNING, "Unable to listen on UNIX socket: %s", strerror(errno) );
     514                return 0;
     515        }
    497516       
    498517        gio = g_io_channel_unix_new(serversock);
     518       
     519        if (gio == NULL) {
     520                log_message( LOGLVL_WARNING, "Unable to create IO channel for unix socket" );
     521                return 0;
     522        }
    499523
    500524        g_io_add_watch(gio, G_IO_IN, new_ipc_client, NULL);
Note: See TracChangeset for help on using the changeset viewer.