Hi Iain,

Am 2012-03-19 10:33, schrieb Iain Hibbert:
> On Sun, 18 Mar 2012, Hendrik Sattler wrote:
>> Am Mittwoch, 14. März 2012, 15:44:01 schrieb Iain Hibbert:
>> > To be honest, any new release (1.6?) with the current changes 
>> would be
>> > welcomed
>> >
>> > As to the API, then yes I do agree that there are some problems. I 
>> would
>> > not choose to use openobex if I were to write an OBEX program, not 
>> least
>> > because the documentation is minimal. I have worked on software 
>> using
>> > openobex and found that it was really difficult to work with. 
>> However, I
>> > don't really have any better ideas :)
>>
>> For a start, I submitted some additional patches to my master 
>> branch.
>> Can you check them out and do some compile and runtime tests for 
>> your BSDs?
>> If everything goes well, the current state will be version 1.6.
>>
>> I compile tested it on Linux, Windows cross-compiled on Linux and 
>> Windows.
>
> No time to investigate further just now can look at it later, but 
> NetBSD
> has SOCK_CLOEXEC but not accept4() .. we have a paccept(2) instead 
> which
> also takes a sigmask, like so:
>
> int paccept(int s, struct sockaddr * restrict addr, socklen t *
> restrict addrlen, const sigset t * restrict sigmask, int flags);
>
> You could do some autoconfig detection for this but its probably just
> simpler to use fcntl all the time..  I mean, the overhead of the 
> extra
> syscall is not likely to be significant in this environment, is it?

In a multi-threaded environment, it is useful to not leak file 
descriptors. fcntl() helps but is not race-free without a lot of hassle.
The non-blocking-io flag (in a non-included later patch) doesn't have 
this problem.

> I don't think any of the other BSDs have SOCK_CLOEXEC or accept4() or
> paccept() so that shouldn't be a problem for them

I will add paccept() support. NetBSD is easily detected using
http://sourceforge.net/apps/mediawiki/predef/index.php?title=Operating_Systems#NetBSD
and I add an accept4() function wrapper:

#if defined(SOCK_CLOEXEC) && defined(__NetBSD__)
static __inline int accept4(int s, struct sockaddr * addr, socklen t 
*addrlen, int flags) {
     return paccept(s, addr, addrlen, NULL, flags);
}
#endif

It seems that SOCK_CLOEXEC and paccept() appeared at the same time 
(NetBSD 6.0), so this should be sufficiently safe.

Thanks for the hint :-)

Regards,

HS


------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here 
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Openobex-users mailing list
Openobex-users@lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/openobex-users

Reply via email to