/*----- function predeclarations -----*/
static void conn_check_work(Conn *conn);
+static void conn_make_some_xmits(Conn *conn);
+static void *conn_write_some_xmits(Conn *conn);
static int filemon_init(void);
static void filemon_setfile(int mainfeed_fd, const char *mainfeed_path);
static void filemon_callback(void);
+static ConnList *conn_determine_right_list(Conn *conn);
static void conn_assign_one_article(ConnList *connlist, Conn **last_assigned);
static void statemc_setstate(StateMachineState newsms, int periods,
const char *forlog, const char *why);
static void check_master_queue(void);
+static void postfork(const char *what);
static void postfork_inputfile(InputFile *ipf);
/*----- configuration options -----*/
static void perhaps_close(int *fd) { if (*fd) { close(*fd); fd=0; } }
-static void *xmalloc(size_t sz) {
- if (!sz) return 0;
- void *r= malloc(sz);
- if (r) return r;
- sysdie("malloc (%ld bytes) failed", (unsigned long)sz);
-}
-
static pid_t xfork(const char *what) {
pid_t child;
a->st_dev == b->st_dev);
}
-static char *sanitise(const char *input, int len) {
+static char *sanitise(const char *input) {
static char sanibuf[100]; /* returns pointer to this buffer! */
const char *p= input;
*q++= '`';
for (;;) {
if (q > sanibuf+sizeof(sanibuf)-8) { strcpy(q,"'.."); break; }
- int c;
- if (len<=0 || !(c= *p++)) { *q++= '\''; *q=0; break; }
+ int c= *p++;
+ if (!c) { *q++= '\''; *q=0; break; }
if (c>=' ' && c<=126 && c!='\\') { *q++= c; continue; }
sprintf(q,"\\x%02x",c);
q += 4;
static void connect_attempt_discard(void) {
if (connecting_sockets[0])
- loop->cancel_fd(connecting_sockets[0]);
+ cancel_fd_read_except(connecting_sockets[0]);
perhaps_close(&connecting_sockets[0]);
perhaps_close(&connecting_sockets[1]);
if (r) sysdie("connect: close parent socket in child");
alarm(connection_setup_timeout);
- if (NNTPconnect(remote_host, port, &cn_from, &cn_to, buf) < 0) {
+ if (NNTPconnect((char*)remote_host, port, &cn_from, &cn_to, buf) < 0) {
if (buf[0]) fatal("connect: rejected: %s", sanitise(buf));
else sysfatal("connect: connection attempt failed");
}
- if (NNTPsendpassword(remote_host, cn_from, cn_to) < 0)
+ if (NNTPsendpassword((char*)remote_host, cn_from, cn_to) < 0)
sysfatal("connect: authentication failed");
if (try_stream) {
if (fputs("MODE STREAM\r\n", cn_to) ||
conn_assign_one_article(&working, &last_assigned);
} else if (idle.head) {
conn_assign_one_article(&idle, &last_assigned);
- } else if (nconns < max_connections && queue.count >= max_queue_per_conn &&
+ } else if (nconns < max_connections &&
+ conn_total_queued_articles(conn) >= max_queue_per_conn &&
!connecting_child && !until_connect) {
until_connect= reconnect_delay_periods;
connect_start();
LIST_REMOVE(*connlist, conn);
Article *art= LIST_REMHEAD(queue);
LIST_ADDTAIL(conn->queue, art);
- LIST_ADD(*conn_determine_right_list(conn), conn);
+ LIST_ADDTAIL(*conn_determine_right_list(conn), conn);
/* This slightly odd arrangement is so that we call conn_check_work
* once after filling the queue for a new connection in
static ConnList *conn_determine_right_list(Conn *conn) {
int inqueue= conn_total_queued_articles(conn);
- assert(inqueue <= max_queue);
+ assert(inqueue <= max_queue_per_conn);
if (inqueue == 0) return &idle;
if (inqueue == conn->max_queue) return &full;
return &working;
}
-static void *conn_writeable(oop_source *l, int fd, int ev, void *u) {
- check_conn_work(u);
+static void *conn_writeable(oop_source *l, int fd, oop_event ev, void *u) {
+ conn_check_work(u);
return OOP_CONTINUE;
}
}
static void vconnfail(Conn *conn, const char *fmt, va_list al)
- __attribute__((printf,2,0));
+ __attribute__((__format__(printf,2,0)));
static void vconnfail(Conn *conn, const char *fmt, va_list al) {
int requeue[art_MaxState];
Article *art;
- while ((art= LIST_REMHEAD(conn->queue))) LIST_ADDTAIL(queue);
+ while ((art= LIST_REMHEAD(conn->queue))) LIST_ADDTAIL(queue, art);
while ((art= LIST_REMHEAD(conn->sent))) {
counts[art->state]++;
if (art->state==art_Unsolicited) art->state= art_Unchecked;
}
static void connfail(Connection *conn, const char *fmt, ...)
- __attribute__((printf,2,3));
+ __attribute__((__format__(printf,2,3)));
static void connfail(Connection *conn, const char *fmt, ...) {
va_list al;
va_start(al,fmt);