MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / didAccept

Function didAccept

modules/network/socket/lwip/modSocket.c:1228–1277  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1226}
1227
1228err_t didAccept(void * arg, struct tcp_pcb * newpcb, err_t err)
1229{
1230 xsListener xsl = arg;
1231 xsSocket xss;
1232 uint8_t i;
1233
1234 tcp_accepted(xsl->skt);
1235
1236#ifdef mxDebug
1237 if (fxInNetworkDebugLoop(xsl->the)) {
1238 modLog("refuse incoming connection while in debugger");
1239 return ERR_ABRT; // lwip will close
1240 }
1241#endif
1242
1243 xss = c_calloc(1, sizeof(xsSocketRecord) - sizeof(xsSocketUDPRemoteRecord));
1244 if (!xss)
1245 return ERR_ABRT; // lwip will close
1246
1247 xss->the = xsl->the;
1248 xss->skt = newpcb;
1249 xss->useCount = 1;
1250 xss->kind = kTCP;
1251
1252 modCriticalSectionBegin();
1253 for (i = 0; i < kListenerPendingSockets; i++) {
1254 if (NULL == xsl->accept[i]) {
1255 xsl->accept[i] = xss;
1256 break;
1257 }
1258 }
1259 modCriticalSectionEnd();
1260
1261 if (kListenerPendingSockets == i) {
1262 modLog("tcp accept queue full");
1263 c_free(xss);
1264 return ERR_ABRT; // lwip will close
1265 }
1266
1267 tcp_arg(xss->skt, xss);
1268 tcp_recv(xss->skt, didReceiveWait);
1269 tcp_sent(xss->skt, didSend);
1270 tcp_err(xss->skt, didError);
1271
1272 socketSetPending((xsSocket)xsl, kPendingAcceptListener);
1273
1274 modInstrumentationAdjust(NetworkSockets, 1);
1275
1276 return ERR_OK;
1277}
1278
1279void socketSetPending(xsSocket xss, uint8_t pending)
1280{

Callers

nothing calls this directly

Calls 2

socketSetPendingFunction · 0.85
fxInNetworkDebugLoopFunction · 0.50

Tested by

no test coverage detected