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

Function cbm_httpd_accept

src/ui/httpd.c:187–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185/* ── Accept ───────────────────────────────────────────────────── */
186
187cbm_http_conn_t *cbm_httpd_accept(cbm_httpd_t *d, int timeout_ms) {
188 if (!d)
189 return NULL;
190 if (wait_readable(d->fd, timeout_ms) != 1)
191 return NULL;
192
193 cbm_sock_t cfd = accept(d->fd, NULL, NULL);
194 if (cfd == CBM_SOCK_BAD)
195 return NULL;
196
197 int one = 1;
198 setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (const char *)&one, sizeof(one));
199#ifdef SO_NOSIGPIPE
200 setsockopt(cfd, SOL_SOCKET, SO_NOSIGPIPE, &one, sizeof(one));
201#endif
202
203 cbm_http_conn_t *c = calloc(1, sizeof(*c));
204 if (!c) {
205 cbm_sock_close(cfd);
206 return NULL;
207 }
208 c->fd = cfd;
209 c->recv_deadline_ms = d->recv_deadline_ms;
210 return c;
211}
212
213void cbm_httpd_conn_close(cbm_http_conn_t *c) {
214 if (!c)

Callers 2

cbm_http_server_runFunction · 0.85
test_httpd.cFile · 0.85

Calls 1

wait_readableFunction · 0.85

Tested by

no test coverage detected