Overview
Features
Download
Documentation
Community
Add-Ons & Services

POCO LSB compliant

General discussion regarding the development of POCO for contributors.

POCO LSB compliant

Postby OmarMVelasco » 19 Jan 2010, 22:31

Hi everyone,

I have tried to build POCO with an LSB compiler. I got some problems when building the Net library. Poco calls ioctl() with the FIONBIO constant which is not included in LSB. From what I have read, there are some open questions about how portable FIONBIO is, and ioctl() is not very portable as many of the commands are device-specific.

Instead of using ioctl () you can use fcntl() with O_NONBLOCK constant ( fcntl(..., O_NONBLOCK, ...) ), which is a POSIX command that should work as ioctl and it is available in the LSB specification.

What do you think about this?

Thanks in advance
Omar
OmarMVelasco
 
Posts: 10
Joined: 15 Jan 2010, 13:37

Re: POCO LSB compliant

Postby guenter » 20 Jan 2010, 07:40

Looks like a good idea. I have created a bug report.
guenter
 
Posts: 1091
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: POCO LSB compliant

Postby OmarMVelasco » 22 Jan 2010, 12:25

Hi,

Perfect!!! A POCO LSB compliant will be released soon!!! There is another thing that is not LSB compliant. In the Net library (RawSocketImpl.c) the constant IP_HDRINCL is used and it is not defined in the LSB specification. Is there another way to avoid to use this constant?

BR
Omar
OmarMVelasco
 
Posts: 10
Joined: 15 Jan 2010, 13:37

Re: POCO LSB compliant

Postby OmarMVelasco » 27 Jan 2010, 09:12

Hi,

Here is a possible patch to make Poco more LSB compliant. I removed the call to ioctl with the FIONBIO constant
and I added a call to fcntl. I have run unittest and all have passed. What do you think?


Code: Select all
Index: Net/src/SocketImpl.cpp
===================================================================
--- Net/src/SocketImpl.cpp   (revision 1318)
+++ Net/src/SocketImpl.cpp   (working copy)
@@ -40,6 +40,7 @@
 #include "Poco/NumberFormatter.h"
 #include "Poco/Timestamp.h"
 #include <string.h> // FD_SET needs memset on some platforms, so we can't use <cstring>
+#include <sys/fcntl.h>
 
 
 using Poco::IOException;
@@ -719,9 +720,21 @@
 
 void SocketImpl::setBlocking(bool flag)
 {
-   int arg = flag ? 0 : 1;
-   ioctl(FIONBIO, arg);
-   _blocking = flag;
+
+   //Get current flags
+   int current_flags;
+   ioctl (FIONREAD, current_flags);
+
+   int arg = flag ? current_flags : current_flags |= O_NONBLOCK;
+   
+    // Set blocking flag
+#if defined(_WIN32)
+    int rc = fcntlsocket (_sockfd, F_SETFL, arg);
+#else
+   int rc = fcntl (_sockfd, F_SETFL, arg);
+#endif   
+
+    if (rc != 0) error();
 }


/Omar
OmarMVelasco
 
Posts: 10
Joined: 15 Jan 2010, 13:37

Re: POCO LSB compliant

Postby OmarMVelasco » 29 Jan 2010, 14:28

Hi,

Is there any comment about the propousal patch?


/Omar
OmarMVelasco
 
Posts: 10
Joined: 15 Jan 2010, 13:37

Re: POCO LSB compliant

Postby guenter » 29 Jan 2010, 15:46

Looks good so far. I'll add this to 1.3.7 when I have time. I also need to run tests on other platforms.
guenter
 
Posts: 1091
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: POCO LSB compliant

Postby OmarMVelasco » 29 Jan 2010, 16:15

Ok, "run test in other platform" this sounds good and I think is needed.

I have a small issue in the Foundation lib, but I can't run the unittest. I think I need to configure my environment.

/Omar
OmarMVelasco
 
Posts: 10
Joined: 15 Jan 2010, 13:37

Re: POCO LSB compliant

Postby OmarMVelasco » 10 Feb 2010, 15:02

Hi again,

The LSB specification define a FALSE and a TRUE constant. In Foundation/src/pcre_internal.h there is a definition like

#ifndef FALSE
typedef int BOOL;

#define FALSE 0
#define TRUE 1
#endif

The problem is that LSB define FALSE and the BOOL is never defined so I get compilation errors. My proposal is to split
the definition in 2 parts

One part for the BOOL type

#ifndef BOOL
typedef int BOOL;
#endif

And the second part for the FALSE and TRUE constants

#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif


What do you think? The patch file looks like

Index: Foundation/src/pcre_internal.h
===================================================================
--- Foundation/src/pcre_internal.h (revision 1318)
+++ Foundation/src/pcre_internal.h (working copy)
@@ -562,9 +562,10 @@
/* Miscellaneous definitions. The #ifndef is to pacify compiler warnings in
environments where these macros are defined elsewhere. */

+#ifndef BOOL
+typedef int BOOL;
+#endif
#ifndef FALSE
-typedef int BOOL;
-
#define FALSE 0
#define TRUE 1
#endif
OmarMVelasco
 
Posts: 10
Joined: 15 Jan 2010, 13:37

Re: POCO LSB compliant

Postby OmarMVelasco » 05 Apr 2010, 22:58

Hi,

What about the last patch?

/Omar
OmarMVelasco
 
Posts: 10
Joined: 15 Jan 2010, 13:37

Re: POCO LSB compliant

Postby alex » 06 Apr 2010, 14:11

OmarMVelasco wrote:What about the last patch?

the way I see it, the problem with it is a maintenance one - whenever we upgrade pcre, we'll have to remember to patch the header.
alex
 
Posts: 1044
Joined: 11 Jul 2006, 16:27
Location: United_States

Next

Return to Contributors

Who is online

Users browsing this forum: No registered users and 1 guest

cron