From 8c689f969db3e81b23ad1bdace924f6f28afa7e0 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 4 Apr 2008 00:13:50 +0200 Subject: [PATCH] Ziplinks appear to work again now. --- include/client.h | 4 ++++ include/send.h | 2 +- src/client.c | 7 +++++++ src/s_serv.c | 22 ++++++++++------------ src/send.c | 12 ++++++------ 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/include/client.h b/include/client.h index f6a1371b..6f3d62a0 100644 --- a/include/client.h +++ b/include/client.h @@ -254,6 +254,10 @@ struct LocalUser /* time challenge response is valid for */ time_t chal_time; + rb_fde_t *ctrlF; /* For servers: + control fd used for sending commands + to servlink */ + struct SlinkRpl slinkrpl; /* slink reply being parsed */ unsigned char *slinkq; /* sendq for control data */ int slinkq_ofs; /* ofset into slinkq */ diff --git a/include/send.h b/include/send.h index 1e5b023d..20b623f1 100644 --- a/include/send.h +++ b/include/send.h @@ -42,7 +42,7 @@ extern void send_pop_queue(struct Client *); extern void send_queued(struct Client *to); -extern void send_queued_slink_write(int fd, void *data); +extern void send_queued_slink_write(rb_fde_t *F, void *data); extern void sendto_one(struct Client *target_p, const char *, ...) AFP(2, 3); extern void sendto_one_notice(struct Client *target_p,const char *, ...) AFP(2, 3); diff --git a/src/client.c b/src/client.c index aa2a0e94..54eeaf5a 100644 --- a/src/client.c +++ b/src/client.c @@ -161,6 +161,7 @@ make_client(struct Client *from) client_p->localClient->lasttime = client_p->localClient->firsttime = rb_current_time(); client_p->localClient->F = NULL; + client_p->localClient->ctrlF = NULL; client_p->preClient = (struct PreClient *) rb_bh_alloc(pclient_heap); @@ -2094,6 +2095,12 @@ close_connection(struct Client *client_p) client_p->localClient->F = NULL; } + if(client_p->localClient->ctrlF) + { + rb_close(client_p->localClient->ctrlF); + client_p->localClient->ctrlF = NULL; + } + rb_linebuf_donebuf(&client_p->localClient->buf_sendq); rb_linebuf_donebuf(&client_p->localClient->buf_recvq); detach_conf(client_p); diff --git a/src/s_serv.c b/src/s_serv.c index bf98cffe..189f3a48 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -218,7 +218,7 @@ collect_zipstats(void *unused) target_p->localClient->slinkq[0] = SLINKCMD_ZIPSTATS; target_p->localClient->slinkq_ofs = 0; target_p->localClient->slinkq_len = 1; - // send_queued_slink_write(target_p->localClient->ctrlfd, target_p); + send_queued_slink_write(target_p->localClient->ctrlF, target_p); } } } @@ -1140,7 +1140,8 @@ server_estab(struct Client *client_p) */ rb_snprintf(note, sizeof note, "slink data: %s", client_p->name); rb_note(client_p->localClient->F, note); - // rb_note(client_p->localClient->ctrlfd, "slink ctrl: %s", client_p->name); + rb_snprintf(note, sizeof note, "slink ctrl: %s", client_p->name); + rb_note(client_p->localClient->ctrlF, note); } else { @@ -1313,7 +1314,7 @@ start_io(struct Client *server) server->localClient->slinkq_len = c; /* schedule a write */ - //XXX send_queued_slink_write(server->localClient->ctrlF, server); + send_queued_slink_write(server->localClient->ctrlF, server); } /* @@ -1407,22 +1408,19 @@ fork_server(struct Client *server) close(data_fds[1]); s_assert(server->localClient); - // server->localClient->ctrlfd = ctrl_fds[0]; + server->localClient->ctrlF = rb_open(ctrl_fds[0], RB_FD_PIPE, "servlink ctrl"); server->localClient->F = rb_open(data_fds[0], RB_FD_PIPE, "servlink data"); + if(!rb_set_nb(server->localClient->ctrlF)) + { + ilog_error("setting a slink fd nonblocking"); + } + if(!rb_set_nb(server->localClient->F)) { ilog_error("setting a slink fd nonblocking"); } - /* if(!rb_set_nb(server->localClient->ctrlfd)) - { - ilog_error("setting a slink fd nonblocking"); - } - - rb_open(server->localClient->ctrlfd, FD_SOCKET, NULL); - */ - read_packet(server->localClient->F, server); } diff --git a/src/send.c b/src/send.c index 9cbfae73..4b64c2d9 100644 --- a/src/send.c +++ b/src/send.c @@ -219,7 +219,7 @@ send_queued_write(rb_fde_t *F, void *data) * side effects - write is rescheduled if queue isnt emptied */ void -send_queued_slink_write(int fd, void *data) +send_queued_slink_write(rb_fde_t *F, void *data) { struct Client *to = data; int retlen; @@ -234,9 +234,9 @@ send_queued_slink_write(int fd, void *data) /* Next, lets try to write some data */ if(to->localClient->slinkq) { - /* retlen = write(to->localClient->ctrlfd, + retlen = rb_write(to->localClient->ctrlF, to->localClient->slinkq + to->localClient->slinkq_ofs, - to->localClient->slinkq_len); */ + to->localClient->slinkq_len); if(retlen < 0) { @@ -270,9 +270,9 @@ send_queued_slink_write(int fd, void *data) } /* if we have any more data, reschedule a write */ - /* if(to->localClient->slinkq_len) - rb_setselect(to->localClient->ctrlfd, - RB_SELECT_WRITE, send_queued_slink_write, to); */ + if(to->localClient->slinkq_len) + rb_setselect(to->localClient->ctrlF, + RB_SELECT_WRITE, send_queued_slink_write, to); } /* sendto_one()