Commit 10f56500 authored by stettberger's avatar stettberger

* Added timeout for connecting to server

parent c16edf1c
......@@ -2,8 +2,8 @@ CC=gcc
prefix=/usr/local
DESTDIR=
TARGET=si
SILCINCLUDE=/usr/include/silc
SILCLIB=/usr/lib/silc
SILCINCLUDE=/usr/include/silc-toolkit
SILCLIB=/usr/lib/silc-toolkit
FILES=si.c mit.c mm.c buddylist.c
CFLAGS=-I${SILCINCLUDE} -Wall -ggdb
LDFLAGS=-L${SILCLIB} -lsilc -lsilcclient -lpthread -ldl
......@@ -11,7 +11,7 @@ LDFLAGS=-L${SILCLIB} -lsilc -lsilcclient -lpthread -ldl
all: ${TARGET}
${TARGET}: ${TARGET}.o
gcc si.o -o si ${LDFLAGS}
${CC} si.o -o si ${LDFLAGS}
${TARGET}.o: ${FILES}
${CC} -c ${CFLAGS} ${TARGET}.c
clean:
......
* Command Replies
SILC_COMMAND_INVITE
SILC_COMMAND_BAN
......@@ -720,7 +720,7 @@ static void print_out(char *channel, char *buf, ...)
FILE *out;
static char buft[8];
time_t t = time(0);
char *tmp;
char *tmp = NULL;
char *msg;
va_list va;
va_start(va, buf);
......@@ -1075,6 +1075,7 @@ void run_once() {
int run(void)
{
int fd;
time_t conn_timeout;
SilcClientParams params;
SilcClientConnectionParams conn_params;
silc_client = malloc(sizeof(*silc_client));
......@@ -1156,13 +1157,22 @@ int run(void)
free(filename);
/* Start connecting to server. This is asynchronous connecting so the
connection is actually created later after we run the client. */
silc_client_connect_to_server(silc_client->client, &conn_params, port,
host, silc_client);
if(silc_client_connect_to_server(silc_client->client, &conn_params, port,
host, silc_client) == -1){
fprintf(stderr, "si: Couldn't connect to server\n");
exit(EXIT_FAILURE);
}
/* Run it one time */
while(!connected)
conn_timeout = time(NULL);
while(!connected) {
silc_client_run_one(silc_client->client);
if ((time(NULL) - conn_timeout ) > 15) {
fprintf(stderr, "si: Couldn't connect to server (Timeout)\n");
exit(EXIT_FAILURE);
}
}
/* Install the SigHandler for SIGINT */
if(signal(SIGINT, sig_handler))
......@@ -1551,8 +1561,7 @@ silc_connected(SilcClient si, SilcClientConnection conn,
if (status >= SILC_CLIENT_CONN_ERROR) {
fprintf(stderr, "si: Could not connect to server\n");
silc_client_close_connection(si, conn);
exit(-1);
return;
exit(EXIT_FAILURE);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment