diff options
-rw-r--r-- | agni.c | 43 | ||||
-rw-r--r-- | sock_conn.c | 4 |
2 files changed, 14 insertions, 33 deletions
@@ -534,11 +534,8 @@ int th_start_client(void *data) qcmd = NULL; } - free(msg); free(uname); - //printf("OUT<<Send %d\n", fret); - } token_destroy(itok); itok = NULL; @@ -555,36 +552,25 @@ int th_start_client(void *data) } } else if (cret == 0) { - //int err_read_conn = errno; - //if ((err_read_conn == EBADF)||(err_read_conn == 11)) + //TODO add lofic to retry number, and thex exit from thread + //hope server where disconnected + + if (irc_reconnect(&conn)==-1) { - //TODO add lofic to retry number, and thex exit from thread - PRINT(">>!READ %d<<\n", cret); - //hope server where disconnected - //close(conn); - - if (irc_reconnect(&conn)==-1) + while (-1 == irc_reconnect(&conn)) { - while (-1 == irc_reconnect(&conn)) - { - printf("Reconnect in 10 sec\n"); - sleep(10); - } - sleep(1); + printf("Reconnect in 10 sec\n"); + sleep(10); } - //send some commands to irc to register nick - snprintf(cmd_buf, TH_CONN_BUF_SZ, "USER %s 0 0 :%s\r\n", cfg->user, cfg->user); - write(conn.conn_fd, cmd_buf, strlen(cmd_buf)); - snprintf(cmd_buf, TH_CONN_BUF_SZ,"NICK %s \r\n", cfg->user); - write(conn.conn_fd, cmd_buf, strlen(cmd_buf)); - + sleep(1); } + //send some commands to irc to register nick + snprintf(cmd_buf, TH_CONN_BUF_SZ, "USER %s 0 0 :%s\r\n", cfg->user, cfg->user); + write(conn.conn_fd, cmd_buf, strlen(cmd_buf)); + snprintf(cmd_buf, TH_CONN_BUF_SZ,"NICK %s \r\n", cfg->user); + write(conn.conn_fd, cmd_buf, strlen(cmd_buf)); } else { - perror("No conn"); - PRINT(">>READ %d <<\n",cret); - PRINT("CRET %d CONN %d LIBC %d\n", cret, conn.err, conn.liberr); - sleep(1); if (conn.err == ERR_SC_TIMEOUT) { printf("TIMEOUT\n"); @@ -609,10 +595,7 @@ int th_start_client(void *data) //send command over queue } - - printf("End client\n"); - PNL(); atomic_fetch_sub( &cfg->running,1); return 0; diff --git a/sock_conn.c b/sock_conn.c index 119dd10..c926dd1 100644 --- a/sock_conn.c +++ b/sock_conn.c @@ -499,7 +499,6 @@ int irc_reconnect(irc_conn *conn) irc_conn reconn; - PNL(); if (conn == NULL) { PERM(); @@ -515,7 +514,7 @@ int irc_reconnect(irc_conn *conn) timeout = timeout; fret = irc_open(hostname, port, &reconn); - if (fret==-1) + if (-1 == fret) { ENL(); return -1; @@ -529,7 +528,6 @@ int irc_reconnect(irc_conn *conn) //BUG lets think about this case deeper //free(hostname); //free(port); - PNL(); memcpy(conn, &reconn, sizeof(irc_conn)); |