1 /* conn.h - network connection state */
9 #define STATE_WANTCOMMAND 0
10 #define STATE_WANTDATA 1
11 #define STATE_SENDJOB 2
12 #define STATE_SENDWORD 3
15 /* A command can be at most LINE_BUF_SIZE chars, including "\r\n". This value
16 * MUST be enough to hold the longest possible command or reply line, which is
17 * currently "release 18446744073709551615 4294967295 4294967295\r\n". */
18 #define LINE_BUF_SIZE 54
32 /* CONN_TYPE_* are bit masks */
33 #define CONN_TYPE_PRODUCER 1
34 #define CONN_TYPE_WORKER 2
35 #define CONN_TYPE_WAITING 4
37 typedef struct conn
*conn
;
40 conn prev
, next
; /* linked list of connections */
46 /* we cannot share this buffer with the reply line because we might read in
47 * command line data for a subsequent command, and we need to store it
49 char cmd
[LINE_BUF_SIZE
]; /* this string is NOT NUL-terminated */
55 char reply_buf
[LINE_BUF_SIZE
]; /* this string IS NUL-terminated */
60 struct job reserved_jobs
; /* doubly-linked list header */
65 conn
make_conn(int fd
, char start_state
);
67 int conn_set_evq(conn c
, const int events
, evh handler
);
68 int conn_update_evq(conn c
, const int flags
);
70 void conn_close(conn c
);
72 int conn_list_any_p(conn head
);
73 conn
conn_remove(conn c
);
74 void conn_insert(conn head
, conn c
);
76 int count_cur_conns();
77 unsigned int count_tot_conns();
78 int count_cur_producers();
79 int count_cur_workers();
81 void conn_set_producer(conn c
);
82 void conn_set_worker(conn c
);