Minor cleanups in relay.c
This commit is contained in:
parent
d09902fb06
commit
b40930997c
17
relay.c
17
relay.c
|
@ -31,6 +31,8 @@ typedef unsigned char u_char;
|
|||
#include "hashtable.h"
|
||||
#include "node.h"
|
||||
|
||||
#define WANT_MESSAGE_TRACE 0
|
||||
|
||||
typedef struct relay_extension_t_ {
|
||||
struct sockaddr_in peername;
|
||||
char peername_str[256];
|
||||
|
@ -59,10 +61,10 @@ static void relay_destructor(node_t *n) {
|
|||
static void relay_handle_message(node_t *n, sexp_t *m) {
|
||||
relay_extension_t *r = n->extension;
|
||||
|
||||
/*
|
||||
#if WANT_MESSAGE_TRACE
|
||||
info("fd %d <-- ", r->fd);
|
||||
sexp_writeln(stderr_h, m);
|
||||
*/
|
||||
#endif
|
||||
|
||||
BCHECK(!sexp_write(r->outh, m), "relay_handle_message sexp_write");
|
||||
}
|
||||
|
@ -112,10 +114,10 @@ static void relay_main(node_t *n) {
|
|||
if (!sexp_read(inh, &message)) goto network_error;
|
||||
INCREF(message);
|
||||
|
||||
/*
|
||||
#if WANT_MESSAGE_TRACE
|
||||
info("fd %d --> ", r->fd);
|
||||
sexp_writeln(stderr_h, message);
|
||||
*/
|
||||
#endif
|
||||
|
||||
if (!(sexp_pairp(message) && sexp_stringp(sexp_head(message)))) {
|
||||
info("Ill-formed message\n");
|
||||
|
@ -143,13 +145,12 @@ static void relay_main(node_t *n) {
|
|||
&& sexp_stringp(sexp_head(sexp_tail(sexp_tail(sexp_tail(sexp_tail(args))))))) {
|
||||
sexp_t *filter_sexp = sexp_head(args);
|
||||
cmsg_bytes_t filter = sexp_data(filter_sexp);
|
||||
sexp_t *reply_sink_and_name = sexp_tail(sexp_tail(sexp_tail(args)));
|
||||
cmsg_bytes_t reply_sink = sexp_data(sexp_head(reply_sink_and_name));
|
||||
cmsg_bytes_t reply_name = sexp_data(sexp_head(sexp_tail(reply_sink_and_name)));
|
||||
sexp_t *reply_sink = sexp_listref(args, 3);
|
||||
sexp_t *reply_name = sexp_listref(args, 4);
|
||||
if (bind_node(filter, n)) {
|
||||
sexp_t *subok = sexp_cons(sexp_cstring("subscribe-ok"), sexp_cons(filter_sexp, NULL));
|
||||
INCREF(subok);
|
||||
post_node(reply_sink, reply_name, subok, sexp_empty_bytes);
|
||||
post_node(sexp_data(reply_sink), sexp_data(reply_name), subok, sexp_empty_bytes);
|
||||
DECREF(subok, sexp_destructor);
|
||||
} else {
|
||||
warn("Bind failed <<%.*s>>\n", filter.len, filter.bytes);
|
||||
|
|
Loading…
Reference in New Issue