static inline int deliver_payload(int raw, int fd, Connection *conn, bstring payload) { int rc = 0; if(raw) { debug("Sending raw message to %d length %d", fd, blength(payload)); rc = Connection_deliver_raw(conn, payload); check(rc != -1, "Error sending raw message to HTTP listener on FD %d, closing them.", fd); } else { debug("Sending BASE64 message to %d length %d", fd, blength(payload)); handler_cap_payload(payload); rc = Connection_deliver(conn, payload); check(rc != -1, "Error sending to MSG listener on FD %d, closing them.", fd); } return 0; error: return -1; }
static inline void handler_process_request(Handler *handler, int id, int fd, Connection *conn, bstring payload) { int rc = 0; check(conn != NULL, "You can't pass NULL conn to this anymore."); if(blength(payload) == 0) { rc = Connection_deliver_raw(conn,NULL); check(rc != -1, "Register disconnect failed for: %d", fd); } else { int raw = conn->type != CONN_TYPE_MSG || handler->raw; rc = deliver_payload(raw, fd, conn, payload); check(rc != -1, "Failed to deliver to connection %d on socket %d", id, fd); } return; error: Register_disconnect(fd); // return ignored return; }