MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / connection_write_full

Function connection_write_full

src/daemon/ipc.c:828–860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

826}
827
828static int connection_write_full(cbm_daemon_ipc_connection_t *connection, const void *buffer,
829 size_t length, uint64_t deadline_ms) {
830 if (!connection || atomic_load_explicit(&connection->poisoned, memory_order_acquire)) {
831 return -1;
832 }
833 size_t offset = 0;
834 while (offset < length) {
835 int ready = poll_until(connection->fd, POLLOUT, deadline_ms);
836 if (ready != 1) {
837 atomic_store_explicit(&connection->poisoned, true, memory_order_release);
838 return ready;
839 }
840#ifdef MSG_NOSIGNAL
841 ssize_t sent =
842 send(connection->fd, (const uint8_t *)buffer + offset, length - offset, MSG_NOSIGNAL);
843#else
844 ssize_t sent = send(connection->fd, (const uint8_t *)buffer + offset, length - offset, 0);
845#endif
846 if (sent > 0) {
847 offset += (size_t)sent;
848 continue;
849 }
850 if (sent == 0) {
851 atomic_store_explicit(&connection->poisoned, true, memory_order_release);
852 return -1;
853 }
854 if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) {
855 atomic_store_explicit(&connection->poisoned, true, memory_order_release);
856 return -1;
857 }
858 }
859 return 1;
860}
861
862cbm_daemon_ipc_endpoint_t *cbm_daemon_ipc_endpoint_new(const char *instance_key,
863 const char *runtime_parent) {

Callers 1

Calls 3

poll_untilFunction · 0.85
sendFunction · 0.85
win_io_onceFunction · 0.85

Tested by

no test coverage detected