| 1005 | } |
| 1006 | |
| 1007 | static int connection_write_full(cbm_daemon_ipc_connection_t *connection, const void *buffer, |
| 1008 | size_t length, uint64_t deadline_ms) { |
| 1009 | if (!connection || atomic_load_explicit(&connection->poisoned, memory_order_acquire)) { |
| 1010 | return -1; |
| 1011 | } |
| 1012 | size_t offset = 0; |
| 1013 | while (offset < length) { |
| 1014 | int ready = poll_until(connection->fd, POLLOUT, deadline_ms); |
| 1015 | if (ready != 1) { |
| 1016 | atomic_store_explicit(&connection->poisoned, true, memory_order_release); |
| 1017 | return ready; |
| 1018 | } |
| 1019 | #ifdef MSG_NOSIGNAL |
| 1020 | ssize_t sent = |
| 1021 | send(connection->fd, (const uint8_t *)buffer + offset, length - offset, MSG_NOSIGNAL); |
| 1022 | #else |
| 1023 | ssize_t sent = send(connection->fd, (const uint8_t *)buffer + offset, length - offset, 0); |
| 1024 | #endif |
| 1025 | if (sent > 0) { |
| 1026 | offset += (size_t)sent; |
| 1027 | continue; |
| 1028 | } |
| 1029 | if (sent == 0) { |
| 1030 | atomic_store_explicit(&connection->poisoned, true, memory_order_release); |
| 1031 | return -1; |
| 1032 | } |
| 1033 | if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) { |
| 1034 | atomic_store_explicit(&connection->poisoned, true, memory_order_release); |
| 1035 | return -1; |
| 1036 | } |
| 1037 | } |
| 1038 | return 1; |
| 1039 | } |
| 1040 | |
| 1041 | cbm_daemon_ipc_endpoint_t *cbm_daemon_ipc_endpoint_new(const char *instance_key, |
| 1042 | const char *runtime_parent) { |
no test coverage detected