Skip to content

Commit

Permalink
Fix bug in 2703 (commadpt) devices
Browse files Browse the repository at this point in the history
While waiting for a bind() to succeed, attempting
a devinit or detach or anything that results in a
command getting sent to the device thread can
result in the command getting ignored or the
device getting hung due to a read from the wrong
end of the command pipe.  Also, the wfd file
descriptor set is specified twice in a call to
select().  The second one should be xfd.  Both
issues are addressed by this fix.
  • Loading branch information
Peter Coghlan committed Nov 6, 2020
1 parent babdf43 commit c315318
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions commadpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,12 +1242,12 @@ static void *commadpt_thread(void *vca)
FD_ZERO(&rfd);
FD_ZERO(&wfd);
FD_ZERO(&xfd);
FD_SET(ca->pipe[1],&rfd);
FD_SET(ca->pipe[0],&rfd);
tv.tv_sec=5;
tv.tv_usec=0;

release_lock(&ca->lock);
rc=select(ca->pipe[1]+1,&rfd,&wfd,&wfd,&tv);
rc=select(ca->pipe[0]+1,&rfd,&wfd,&xfd,&tv);
obtain_lock(&ca->lock);
/*
* Check for a shutdown condition again after the sleep
Expand All @@ -1262,7 +1262,7 @@ static void *commadpt_thread(void *vca)
if(rc!=0)
{
/* Ignore any other command at this stage */
read_pipe(ca->pipe[1],&b,1);
read_pipe(ca->pipe[0],&b,1);
ca->curpending=COMMADPT_PEND_IDLE;
signal_condition(&ca->ipc);
}
Expand Down

0 comments on commit c315318

Please sign in to comment.