cs->data = data;
}
+static inline struct wait_list *wl_set_waitcb(struct wait_list *wl, struct task *(*cb)(struct task *, void *, unsigned short), void *ctx)
+{
+ if (!wl->task->process) {
+ wl->task->process = cb;
+ wl->task->context = ctx;
+ }
+ return wl;
+}
+
/* Installs the connection's mux layer for upper context <ctx>.
* Returns < 0 on error.
*/
goto out_wakeup;
}
if (b_data(&check->bo)) {
- if (!cs->wait_list.task->process) {
- cs->wait_list.task->process = event_srv_chk_w;
- cs->wait_list.task->context = cs;
- }
- conn->mux->subscribe(cs, SUB_CAN_SEND, &cs->wait_list);
+ conn->mux->subscribe(cs, SUB_CAN_SEND, wl_set_waitcb(&cs->wait_list, event_srv_chk_w, cs));
goto out;
}
}
}
}
/* We couldn't send all of our data, let the mux know we'd like to send more */
- if (co_data(oc)) {
- if (!cs->wait_list.task->process) {
- cs->wait_list.task->process = si_cs_send;
- cs->wait_list.task->context = ctx;
- }
- conn->mux->subscribe(cs, SUB_CAN_SEND, &cs->wait_list);
- }
+ if (co_data(oc))
+ conn->mux->subscribe(cs, SUB_CAN_SEND, wl_set_waitcb(&cs->wait_list, si_cs_send, ctx));
+
wake_others:
/* Maybe somebody was waiting for this conn_stream, wake them */
if (did_send) {