1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

improve queuing commands, patch by Timothy Hatcher (Bug 168)

(patch changed so it doesn't wait one second after the 001 event)

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@3698 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Wouter Coekaerts 2005-01-03 19:22:53 +00:00 committed by coekie
parent a38c7d1631
commit b52bbcfbbf
2 changed files with 39 additions and 19 deletions

View File

@ -291,7 +291,7 @@ static void event_whois_ircop(SERVER_REC *server, const char *data)
static void event_nick_in_use(IRC_SERVER_REC *server, const char *data) static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
{ {
char *str; char *str, *cmd;
int n; int n;
g_return_if_fail(data != NULL); g_return_if_fail(data != NULL);
@ -330,7 +330,9 @@ static void event_nick_in_use(IRC_SERVER_REC *server, const char *data)
} }
} }
irc_send_cmdv(server, "NICK %s", server->nick); cmd = g_strdup_printf("NICK %s", server->nick);
irc_send_cmd_now(server, cmd);
g_free(cmd);
} }
static void event_target_unavailable(IRC_SERVER_REC *server, const char *data) static void event_target_unavailable(IRC_SERVER_REC *server, const char *data)

View File

@ -102,32 +102,38 @@ static void send_message(SERVER_REC *server, const char *target,
static void server_init(IRC_SERVER_REC *server) static void server_init(IRC_SERVER_REC *server)
{ {
IRC_SERVER_CONNECT_REC *conn; IRC_SERVER_CONNECT_REC *conn;
char hostname[100], *address, *ptr, *username; char hostname[100], *address, *ptr, *username, *cmd;
g_return_if_fail(server != NULL); g_return_if_fail(server != NULL);
conn = server->connrec; conn = server->connrec;
if (conn->proxy != NULL && conn->proxy_password != NULL && if (conn->proxy != NULL && conn->proxy_password != NULL &&
*conn->proxy_password != '\0') *conn->proxy_password != '\0') {
irc_send_cmdv(server, "PASS %s", conn->proxy_password); cmd = g_strdup_printf("PASS %s", conn->proxy_password);
irc_send_cmd_now(server, cmd);
g_free(cmd);
}
if (conn->proxy != NULL && conn->proxy_string != NULL) if (conn->proxy != NULL && conn->proxy_string != NULL) {
irc_send_cmdv(server, conn->proxy_string, conn->address, conn->port); cmd = g_strdup_printf(conn->proxy_string, conn->address, conn->port);
irc_send_cmd_now(server, cmd);
g_free(cmd);
}
if (conn->password != NULL && *conn->password != '\0') { if (conn->password != NULL && *conn->password != '\0') {
/* send password */ /* send password */
server->cmdcount = 0; cmd = g_strdup_printf("PASS %s", conn->password);
irc_send_cmdv(server, "PASS %s", conn->password); irc_send_cmd_now(server, cmd);
g_free(cmd);
} }
/* send nick */ /* send nick */
server->cmdcount = 0; cmd = g_strdup_printf("NICK %s", conn->nick);
irc_send_cmdv(server, "NICK %s", conn->nick); irc_send_cmd_now(server, cmd);
g_free(cmd);
/* send user/realname */ /* send user/realname */
server->cmdcount = 0;
if (gethostname(hostname, sizeof(hostname)) != 0 || *hostname == '\0') if (gethostname(hostname, sizeof(hostname)) != 0 || *hostname == '\0')
strcpy(hostname, "xx"); strcpy(hostname, "xx");
@ -163,15 +169,15 @@ static void server_init(IRC_SERVER_REC *server)
ptr = strchr(username, ' '); ptr = strchr(username, ' ');
if (ptr != NULL) *ptr = '\0'; if (ptr != NULL) *ptr = '\0';
irc_send_cmdv(server, "USER %s %s %s :%s", username, hostname, cmd = g_strdup_printf("USER %s %s %s :%s", username, hostname, address, conn->realname);
address, conn->realname); irc_send_cmd_now(server, cmd);
g_free(cmd);
g_free(username); g_free(username);
server->cmdcount = 0;
if (conn->proxy != NULL && conn->proxy_string_after != NULL) { if (conn->proxy != NULL && conn->proxy_string_after != NULL) {
irc_send_cmdv(server, conn->proxy_string_after, cmd = g_strdup_printf(conn->proxy_string_after, conn->address, conn->port);
conn->address, conn->port); irc_send_cmd_now(server, cmd);
g_free(cmd);
} }
server->isupport = g_hash_table_new((GHashFunc) g_istr_hash, server->isupport = g_hash_table_new((GHashFunc) g_istr_hash,
@ -182,6 +188,13 @@ static void server_init(IRC_SERVER_REC *server)
g_hash_table_insert(server->isupport, g_strdup("PREFIX"), g_strdup("(ohv)@%+")); g_hash_table_insert(server->isupport, g_strdup("PREFIX"), g_strdup("(ohv)@%+"));
server->cmdcount = 0; server->cmdcount = 0;
/* prevent the queue from sending too early, we have a max cut off of 120 secs */
/* this will reset to 1 sec after we get the 001 event */
GTimeVal now;
g_get_current_time(&now);
memcpy(&((IRC_SERVER_REC *)server)->wait_cmd, &now, sizeof(GTimeVal));
((IRC_SERVER_REC *)server)->wait_cmd.tv_sec += 120;
} }
SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn) SERVER_REC *irc_server_init_connect(SERVER_CONNECT_REC *conn)
@ -535,6 +548,11 @@ static void event_connected(IRC_SERVER_REC *server, const char *data, const char
server->connected = 1; server->connected = 1;
server->real_connect_time = time(NULL); server->real_connect_time = time(NULL);
/* let the queue send now that we are identified */
GTimeVal now;
g_get_current_time(&now);
memcpy(&server->wait_cmd, &now, sizeof(GTimeVal));
if (server->connrec->usermode != NULL) { if (server->connrec->usermode != NULL) {
/* wait a second and then send the user mode */ /* wait a second and then send the user mode */
g_timeout_add(1000, (GSourceFunc) sig_set_user_mode, server); g_timeout_add(1000, (GSourceFunc) sig_set_user_mode, server);