+ struct wsj1_call *call, *ncall;
+ struct afb_wsj1_msg *msg;
+ char *text;
+ int len;
+
+ static const char error_object_str[] = "{"
+ "\"jtype\":\"afb-reply\","
+ "\"request\":{"
+ "\"status\":\"disconnected\","
+ "\"info\":\"server hung up\"}}";
+
+ ncall = __atomic_exchange_n(&wsj1->calls, NULL, __ATOMIC_RELAXED);
+ while (ncall) {
+ call = ncall;
+ ncall = call->next;
+ len = asprintf(&text, "[%d,\"%s\",%s]", RETERR, call->id, error_object_str);
+ if (len > 0) {
+ msg = wsj1_msg_make(wsj1, text, (size_t)len);
+ if (msg != NULL) {
+ call->callback(call->closure, msg);
+ afb_wsj1_msg_unref(msg);
+ }
+ }
+ free(call);
+ }
+