public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: sem_trywait returns EAGAIN (rather than returning -1 and setting errno)
@ 2002-02-28  6:22 Robert Collins
  2002-02-28 14:20 ` Andrew T. Schnable
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Collins @ 2002-02-28  6:22 UTC (permalink / raw)
  To: cygwin; +Cc: Andrew T. Schnable

FWIW, I've patched sem_trywait and sem_wait. I haven't looked for further cases of misbehaviour though.

Rob

> -----Original Message-----
> From: Christopher Faylor [mailto:cgf@redhat.com] 

> As Robert indicated, in the vast majority of those cases, 
> this was, in fact, the right thing to do.
> 
> It's apparently not the right thing to do in the case of 
> sem_trywait, so a patch will be required:  
> http://cygwin.com/contrib.html .


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: sem_trywait returns EAGAIN (rather than returning -1 and setting errno)
@ 2002-02-28 14:24 Robert Collins
  0 siblings, 0 replies; 13+ messages in thread
From: Robert Collins @ 2002-02-28 14:24 UTC (permalink / raw)
  To: Andrew T. Schnable, cygwin



> -----Original Message-----
> From: Andrew T. Schnable [mailto:schnable@enteract.com] 
> returning -1 and setting errno)
> 
> 
> I think all the sem_* functions are broken similarly.  I have 
> the threads.cc file modified 
> and was going to try and submit patches, but I am having some 
> issues getting the regression tests working (even before I 
> put my changes in...)  A soon as I get these issues resolved 
> and verify my fixes, I can try and submit 
> a patch for everything (like all good cygwin users should!)  
> (Unless of course you beat me to it - and at this rate - you will!)
> 
> Thanks for helping me out with this.

No probs. Just drop the patch in , properly changelogged and formatted.
I'll eyeball it for regressions (The pthreads code is (mostly) trivial,
so I comfortable with this.). I/We'll need to write some new regression
tests though. 

Rob

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* RE: sem_trywait returns EAGAIN (rather than returning -1 and setting errno)
@ 2002-02-26 14:11 Robert Collins
  2002-02-26 14:51 ` Christopher Faylor
  0 siblings, 1 reply; 13+ messages in thread
From: Robert Collins @ 2002-02-26 14:11 UTC (permalink / raw)
  To: cygwin



> -----Original Message-----
> From: Christopher Faylor [mailto:cgf@redhat.com] 

> On Tue, Feb 26, 2002 at 08:37:35PM +1100, Robert Collins wrote:
> >The problem should _not_ be endemic in the pthreads code, as 
> I rewrote 
> >nearly all the pthread* functions from the P1003.1 draft spec.
> 
> % grep 'return E' thread.cc

*Sigh*. That just shows that that is what the code is meant to do.
If you check the spec, you'll see that most of the pthread functions are meant to return the error number.

i.e. picking a function at random - pthread_mutex_lock 
"
RETURN VALUE
If successful, the pthread_mutex_lock( ) and pthread_mutex_unlock( ) functions shall return zero;
otherwise, an error number shall be returned to indicate the error.
"


Rob

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread
* sem_trywait returns EAGAIN (rather than returning -1 and setting errno)
@ 2002-02-25 19:25 Andrew T. Schnable
  2002-02-25 23:04 ` Christopher Faylor
  0 siblings, 1 reply; 13+ messages in thread
From: Andrew T. Schnable @ 2002-02-25 19:25 UTC (permalink / raw)
  To: cygwin

Greetings,

    I was doing some pthreads/semaphore work and I tracked down a
problem in my code to a bug in sem_trywait.  Posix sem_trywait is defined as
returning -1 and setting errno to EAGAIN if the semaphore would have
blocked.
The cygwin implementation returns EAGAIN an leaves errno unchanged.

    Has anyone else encountered this problem and provided a fix?

Andy
schnable@enteract.com

PS. The problem seems to be in thread.cc (semaphore::TryWait) -  I don't see
much
stderr setting anywhere in this file - is this verboten - or just
overlooked?


int
semaphore::TryWait ()
{
  /*FIXME: signals should be able to interrupt semaphores...
   *We probably need WaitForMultipleObjects here.
   */
  if (WaitForSingleObject (win32_obj_id, 0) == WAIT_TIMEOUT)
    return EAGAIN;
  currentvalue--;
  return 0;
}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2002-03-04 16:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-28  6:22 sem_trywait returns EAGAIN (rather than returning -1 and setting errno) Robert Collins
2002-02-28 14:20 ` Andrew T. Schnable
2002-03-04  8:06   ` Gerald S. Williams
  -- strict thread matches above, loose matches on Subject: below --
2002-02-28 14:24 Robert Collins
2002-02-26 14:11 Robert Collins
2002-02-26 14:51 ` Christopher Faylor
2002-02-26 16:28   ` Andrew T. Schnable
2002-02-26 16:39     ` Christopher Faylor
2002-02-26 22:04       ` Andrew T. Schnable
2002-02-25 19:25 Andrew T. Schnable
2002-02-25 23:04 ` Christopher Faylor
2002-02-26  1:44   ` Robert Collins
2002-02-26  8:17     ` Christopher Faylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).