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

Function didReceive

xs/platforms/esp/xsPlatform.c:307–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307static err_t didReceive(void * arg, struct tcp_pcb * pcb, struct pbuf * p, err_t err)
308{
309 txMachine* the = arg;
310 uint8_t i;
311 err_t result = ERR_OK;
312
313 xmodLog(" didReceive - ENTER");
314
315 if (NULL == p) {
316 xmodLog(" didReceive - CONNECTION LOST");
317 for (i = 0; i < kDebugReaderCount; i++) {
318 if (the->readers[i])
319 pbuf_free(the->readers[i]);
320 the->readers[i] = NULL;
321 }
322
323 if (the->connection) {
324/*
325 tcp_recv(the->connection, NULL);
326 tcp_err(the->connection, NULL);
327#if ESP32
328#else
329 tcp_close(the->connection);
330 tcp_abort(the->connection); // not _safe inside callback. must call tcp_abort on ESP8266 or memory leak
331#endif
332*/
333 the->connection = NULL;
334
335 return ERR_ABRT;
336 }
337 return ERR_OK;
338 }
339
340 mxDebugMutexTake();
341
342 for (i = 0; i < kDebugReaderCount; i++) {
343 if (NULL == the->readers[i]) {
344 the->readers[i] = p;
345 p = NULL;
346 if (i == 0)
347 the->readerOffset = 0;
348 break;
349 }
350 }
351
352 if (NULL == p) {
353 if (!the->debugNotifyOutstanding) {
354 the->debugNotifyOutstanding = true;
355 modMessagePostToMachine(the, NULL, 0xffff, doDebugCommand, the);
356 }
357 }
358 else {
359 modLog(" debug receive overflow");
360 result = ERR_MEM;
361 }
362
363 mxDebugMutexGive();
364

Callers

nothing calls this directly

Calls 1

modMessagePostToMachineFunction · 0.70

Tested by

no test coverage detected