diff options
Diffstat (limited to 'agni.c')
-rw-r--r-- | agni.c | 43 |
1 files changed, 13 insertions, 30 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; |