Cleanup create_ipc_socket() and ensure it detects all errors in
connect_by_number(). Make function static since it is only used in one source file. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@145 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
@@ -330,7 +330,6 @@ extern short ospeed;
|
||||
#endif
|
||||
|
||||
void reattach_tty(char *, char *);
|
||||
int create_ipc_socket(void);
|
||||
void init_socketpath(void);
|
||||
void kill_attached_if_needed(int);
|
||||
void setup_pid();
|
||||
|
||||
@@ -2577,17 +2577,20 @@ int i, j;
|
||||
}
|
||||
}
|
||||
|
||||
int create_ipc_socket(void)
|
||||
static int create_ipc_socket(void)
|
||||
{
|
||||
int s = -1,
|
||||
u = -1;
|
||||
int s = -1, u = -1;
|
||||
unsigned short port = 0;
|
||||
char buf[BIG_BUFFER_SIZE+1];
|
||||
|
||||
init_socketpath();
|
||||
|
||||
if ((s = connect_by_number(NULL, &port, SERVICE_SERVER, PROTOCOL_TCP, 0)) != -1)
|
||||
if ((s = connect_by_number(NULL, &port, SERVICE_SERVER, PROTOCOL_TCP, 0)) < 0)
|
||||
{
|
||||
char buf[BIG_BUFFER_SIZE+1];
|
||||
fprintf(stderr, "error creating socket (%d: %s)\r\n", s, strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
sprintf(buf, socket_path, port);
|
||||
if ((u = open(buf, O_CREAT|O_WRONLY, 0600)) != -1)
|
||||
{
|
||||
@@ -2604,11 +2607,9 @@ unsigned short port = 0;
|
||||
set_non_blocking(s);
|
||||
add_socketread(s, port, 0, socket_path, handle_reconnect, NULL);
|
||||
save_ipc = s;
|
||||
|
||||
return 0;
|
||||
}
|
||||
fprintf(stderr, "error creating socket\r\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void do_detach(int pid, char *args)
|
||||
|
||||
Reference in New Issue
Block a user