Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-05-01 01:48:22 UTC
Modified files:
ChangeLog ircd/ircd_auth.c
Log message:
Fix several bugs in iauth code.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.617 ircu2.10/ChangeLog:1.618
--- ircu2.10/ChangeLog:1.617 Wed Apr 27 19:00:05 2005
+++ ircu2.10/ChangeLog Sat Apr 30 18:48:11 2005
@@ -1,3 +1,13 @@
+2005-04-30 Michael Poole <[EMAIL PROTECTED]>
+
+ * ircd/ircd_auth.c (iauth_connect): Initialize (but do not add)
+ timer here and set fd to -1.
+ (iauth_schedule_reconnect): Rewrite to handle previously
+ initialized timer.
+ (iauth_reconnect): If server is connected, disconnect first.
+ Update socket generator fd before calling socket_add().
+ (iauth_read): When reading 0 bytes (EOF), reconnect.
+
2005-04-27 Michael Poole <[EMAIL PROTECTED]>
* ircd/ircd_parser.y: Report non-existent class names as errors
Index: ircu2.10/ircd/ircd_auth.c
diff -u ircu2.10/ircd/ircd_auth.c:1.13 ircu2.10/ircd/ircd_auth.c:1.14
--- ircu2.10/ircd/ircd_auth.c:1.13 Sun Mar 20 08:06:17 2005
+++ ircu2.10/ircd/ircd_auth.c Sat Apr 30 18:48:12 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief IAuth client implementation for an IRC server.
- * @version $Id: ircd_auth.c,v 1.13 2005/03/20 16:06:17 entrope Exp $
+ * @version $Id: ircd_auth.c,v 1.14 2005/05/01 01:48:12 entrope Exp $
*/
#include "config.h"
@@ -243,7 +243,9 @@
memset(&i_addr(iauth), 0, sizeof(i_addr(iauth)));
i_port(iauth) = port;
iauth_active = iauth;
+ timer_init(&i_reconn_timer(iauth));
i_reconnect(iauth) = reconnect;
+ s_fd(&i_socket(iauth)) = -1;
iauth_reconnect(iauth);
}
if (passwd)
@@ -435,9 +437,12 @@
static void iauth_schedule_reconnect(struct IAuth *iauth)
{
struct Timer *timer;
- assert(!t_active(&i_reconn_timer(iauth)));
- timer = timer_init(&i_reconn_timer(iauth));
- timer_add(timer, iauth_reconnect_ev, iauth, TT_RELATIVE, i_reconnect(iauth));
+ timer = &i_reconn_timer(iauth);
+ if (t_onqueue(timer))
+ timer_chg(timer, TT_RELATIVE, i_reconnect(iauth));
+ else
+ timer_add(&i_reconn_timer(iauth), iauth_reconnect_ev,
+ iauth, TT_RELATIVE, i_reconnect(iauth));
}
/** Initiate a (re-)connection to \a iauth.
@@ -449,6 +454,8 @@
IOResult result;
int fd;
+ if (s_fd(&i_socket(iauth)) != -1)
+ iauth_disconnect(iauth);
Debug((DEBUG_INFO, "IAuth attempt connection to %s port %p.", i_host(iauth),
i_port(iauth)));
if (!irc_in_addr_valid(&i_addr(iauth).addr)
&& !ircd_aton(&i_addr(iauth).addr, i_host(iauth))) {
@@ -472,6 +479,7 @@
sendto_opmask_butone(0, SNO_OLDSNO, "IAuth reconnect unable to initiate
connection: %s", strerror(errno));
return;
}
+ s_fd(&i_socket(iauth)) = fd;
if (!socket_add(&i_socket(iauth), iauth_sock_callback, iauth,
(result == IO_SUCCESS) ? SS_CONNECTED : SS_CONNECTING,
SOCK_EVENT_READABLE | SOCK_EVENT_WRITABLE, fd)) {
@@ -494,6 +502,10 @@
length = 0;
if (IO_FAILURE == os_recv_nonb(s_fd(&i_socket(iauth)), readbuf,
sizeof(readbuf), &length))
return;
+ if (length == 0) {
+ iauth_reconnect(iauth);
+ return;
+ }
i_recvB(iauth) += length;
if (i_recvB(iauth) > 1023) {
i_recvK(iauth) += i_recvB(iauth) >> 10;
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches