[Vm-dev] Cog: invalid nanosleep argument (i.e. socket errors)

Henrik Johansen henrik.s.johansen at veloxit.no
Fri Aug 13 14:38:02 UTC 2010

I think I figured out why Cog some times terminates when downloading large files on OSX;
An oversleep which is interrupted can be returned as a t_time struct with tv_sec -1 and tv_nsec close to 999999999.

The while check is 
nanosleep (&naptime, &naptime) == -1 && naptime.tv_sec > 0 1|| naptime.tv_nsec > MINSLEEPNS

or so, so when an interrupt is encountered which has tv_sec = -1, you will get the invalid argument error.

rewriting it to
naptime.tvsec > -1 && naptime.tv_nsec > MINSLEEPNS && nanosleep(&naptime, &naptime) == -1

I no longer had  crashes in 99% of hte cases when evaluating the following test: 

HTTPSocket httpGetDocument: 'http://www.squeaksource.com/Pharo/Morphic-stephane_ducasse.334.mcz'.

I've attached the sqUnixHeartbeat.c.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: sqUnixHeartbeat.c.zip
Type: application/zip
Size: 6929 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20100813/4afc952f/sqUnixHeartbeat.c.zip

More information about the Vm-dev mailing list