| 371 | } |
| 372 | |
| 373 | static void stream_con_free(struct stream_con *con) |
| 374 | { |
| 375 | struct list_head *it, *tmp; |
| 376 | struct jsonrpc_cmd *cmd; |
| 377 | |
| 378 | if (con->pending_writes != 0) |
| 379 | reactor_del_all(con->fd, con->id, 0); |
| 380 | else |
| 381 | reactor_del_reader(con->fd, con->id, 0); |
| 382 | if (con->pending_buffer.len) |
| 383 | pkg_free(con->pending_buffer.s); |
| 384 | |
| 385 | list_for_each_safe(it, tmp, &con->cmds) { |
| 386 | cmd = list_entry(it, struct jsonrpc_cmd, list); |
| 387 | if (cmd->job->async_ctx.status_cb) |
| 388 | stream_dispatch_status_cb(&cmd->job->async_ctx, EVI_STATUS_FAIL); |
| 389 | list_del(&cmd->list); |
| 390 | jsonrpc_cmd_free(cmd); |
| 391 | } |
| 392 | |
| 393 | shutdown(con->fd, SHUT_RDWR); |
| 394 | close(con->fd); |
| 395 | /* remove from the list */ |
| 396 | list_del(&con->list); |
| 397 | pkg_free(con); |
| 398 | } |
| 399 | |
| 400 | |
| 401 | static void handle_new_stream(stream_send_t *stream) |
no test coverage detected