Skip to content

Commit

Permalink
Invalid socket, but still prone to race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
FreddieAkeroyd committed Dec 20, 2023
1 parent 82a38bd commit f13e70e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion asyn/drvAsynSerial/drvAsynIPServerPort.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static void connectionListener(void *drvPvt)
asynPrint(pasynUser, ASYN_TRACE_FLOW,
"drvAsynIPServerPort: %s started listening for connections on %s\n",
tty->portName, tty->serverInfo);
while (1) {
while (tty->fd != INVALID_SOCKET) {
if (tty->socketType == SOCK_DGRAM) {
if ((tty->UDPbufferPos == 0) && (tty->UDPbufferSize == 0)) {
tty->UDPbufferSize = recvfrom(tty->fd, tty->UDPbuffer, THEORETICAL_UDP_MAX_SIZE , 0, NULL, NULL);
Expand Down Expand Up @@ -498,6 +498,7 @@ static void ttyCleanup(void *pPvt)
if (tty->fd >= 0) {
asynPrint(tty->pasynUser, ASYN_TRACE_FLOW, "drvAsynIPServerPort:ttyCleanup %s: shutdown socket %d\n", tty->portName, tty->fd);
epicsSocketDestroy(tty->fd);
tty->fd = INVALID_SOCKET;
}
free(tty->portName);
free(tty->serverInfo);
Expand Down

0 comments on commit f13e70e

Please sign in to comment.