Skip to content

Commit

Permalink
Merge pull request #30 from ISISComputingGroup/avoid_sharing_pasynuser
Browse files Browse the repository at this point in the history
Avoid sharing asynUser
  • Loading branch information
Tom-Willemsen authored Jul 8, 2024
2 parents 7d7aa20 + 697caf9 commit 83ce4d0
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions asyn/drvAsynSerial/drvAsynSerialPortWin32.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,13 @@ static int waitForBytes(ttyController_t *tty, asynUser* pasynUser, double timeou
/* monitor and print requested comm events */
static void monitorComEvents(void* arg)
{
/* if we wanted to asynPrint() etc then we probably need to duplicateAsynUser() as
sharing tty->pasynUser is not recommended. However i was not sure how freeAsynUser with this duplicate
and disconnect() interact, but as we don't need to asynPrint explicitly i'll just use printf instead */
char datetime[64];
ttyController_t *tty = (ttyController_t *)arg;
DWORD evtMask, error, readTotal;
asynPrint(tty->pasynUser, ASYN_TRACE_FLOW,
"%s started monitorComEvents thread.\n", tty->serialDeviceName);
printf("%s started monitorComEvents thread.\n", tty->serialDeviceName);
while(1)
{
if (GetCommMask(tty->commHandle, &evtMask) == 0 || evtMask == 0)
Expand Down Expand Up @@ -270,8 +272,7 @@ static void monitorComEvents(void* arg)
printf("%s: %s COM event: last character sent from output buffer\n", datetime, tty->serialDeviceName);
}
}
asynPrint(tty->pasynUser, ASYN_TRACE_FLOW,
"%s terminated monitorComEvents thread.\n", tty->serialDeviceName);
printf("%s terminated monitorComEvents thread.\n", tty->serialDeviceName);
}

/*
Expand Down

0 comments on commit 83ce4d0

Please sign in to comment.