You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Andrew Stitcher <as...@redhat.com> on 2010/02/11 16:02:33 UTC

Re: qmfengine on windows.

On Wed, 2010-02-10 at 13:49 -0600, Timothy St. Clair wrote:
> Ken - 
> 
> Attached is a patch I used to fix a qmfengine build issue I was having
> on windows.  Probably want to validate it.
> 
> patch -p2 -i <patchfile>

Two points:

1. [procedural] This patch needs to be attached to an upstream qpid 
Jira for it to be considered by all the relevant qpid devs.

2. Please don't do it this way. We have absolutely avoided using #ifdef
when not essential. And I think you'll find that they are very rarely
essential. The way we do this in the qpid C++ code is to have entirely
separate Unix and Win32 implementations in different files and only link
one of the files for a given platform.

Whatever you think of this strategy, and it has some downsides, that is
the way we do it.

Offending part of the patch below.

[Sent to qpid dev list, to make this last point there]

Andrew


--- a/qpid-cpp-mrg-0.7.904602/cpp/src/qmf/engine/ResilientConnection.cpp
+++ b/qpid-cpp-mrg-0.7.904602/cpp/src/qmf/engine/ResilientConnection.cpp
@@ -39,8 +39,15 @@
 #include <set>
 #include <boost/intrusive_ptr.hpp>
 #include <boost/noncopyable.hpp>
-#include <unistd.h>
 #include <fcntl.h>
+#ifndef WIN32
+       #include <unistd.h>
+#else 
+       #include <io.h>
+       #include <winsock2.h>
+       #define write _write
+#endif
+
 
 using namespace std;
 using namespace qmf::engine;
@@ -333,8 +340,13 @@ void ResilientConnectionImpl::setNotifyFd(int fd)
 {
     notifyFd = fd;
     if (notifyFd > 0) {
+#ifndef WIN32
         int original = fcntl(notifyFd, F_GETFL);
         fcntl(notifyFd, F_SETFL, O_NONBLOCK | original);
+#else
+               u_long iMode=1;
+               ioctlsocket(notifyFd, FIONBIO, &iMode);
+#endif
     }
 }
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: qmfengine on windows.

Posted by "Timothy St. Clair" <ts...@redhat.com>.
Duly noted. 

Is there a wiki which outlines practices/standards in case we run across
anything else?

Cheers,
Tim

On Thu, 2010-02-11 at 10:02 -0500, Andrew Stitcher wrote:
> On Wed, 2010-02-10 at 13:49 -0600, Timothy St. Clair wrote:
> > Ken - 
> > 
> > Attached is a patch I used to fix a qmfengine build issue I was having
> > on windows.  Probably want to validate it.
> > 
> > patch -p2 -i <patchfile>
> 
> Two points:
> 
> 1. [procedural] This patch needs to be attached to an upstream qpid 
> Jira for it to be considered by all the relevant qpid devs.
> 
> 2. Please don't do it this way. We have absolutely avoided using #ifdef
> when not essential. And I think you'll find that they are very rarely
> essential. The way we do this in the qpid C++ code is to have entirely
> separate Unix and Win32 implementations in different files and only link
> one of the files for a given platform.
> 
> Whatever you think of this strategy, and it has some downsides, that is
> the way we do it.
> 
> Offending part of the patch below.
> 
> [Sent to qpid dev list, to make this last point there]
> 
> Andrew
> 
> 
> --- a/qpid-cpp-mrg-0.7.904602/cpp/src/qmf/engine/ResilientConnection.cpp
> +++ b/qpid-cpp-mrg-0.7.904602/cpp/src/qmf/engine/ResilientConnection.cpp
> @@ -39,8 +39,15 @@
>  #include <set>
>  #include <boost/intrusive_ptr.hpp>
>  #include <boost/noncopyable.hpp>
> -#include <unistd.h>
>  #include <fcntl.h>
> +#ifndef WIN32
> +       #include <unistd.h>
> +#else 
> +       #include <io.h>
> +       #include <winsock2.h>
> +       #define write _write
> +#endif
> +
>  
>  using namespace std;
>  using namespace qmf::engine;
> @@ -333,8 +340,13 @@ void ResilientConnectionImpl::setNotifyFd(int fd)
>  {
>      notifyFd = fd;
>      if (notifyFd > 0) {
> +#ifndef WIN32
>          int original = fcntl(notifyFd, F_GETFL);
>          fcntl(notifyFd, F_SETFL, O_NONBLOCK | original);
> +#else
> +               u_long iMode=1;
> +               ioctlsocket(notifyFd, FIONBIO, &iMode);
> +#endif
>      }
>  }
>  
> 
> 


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: qmfengine on windows.

Posted by Ken Giusti <kg...@redhat.com>.
Thanks Andrew - points noted.

I created a Jira on behalf of Tim containing his patch.  

https://issues.apache.org/jira/browse/QPID-2401

As noted, I didn't grant license for inclusion, as I did not originate the patch, and it cannot be included as is.

I don't have immediate access to a windows build env, so I cannot investigate the issue right now.


-K

----- "Andrew Stitcher" <as...@redhat.com> wrote:

> On Wed, 2010-02-10 at 13:49 -0600, Timothy St. Clair wrote:
> > Ken - 
> > 
> > Attached is a patch I used to fix a qmfengine build issue I was
> having
> > on windows.  Probably want to validate it.
> > 
> > patch -p2 -i <patchfile>
> 
> Two points:
> 
> 1. [procedural] This patch needs to be attached to an upstream qpid 
> Jira for it to be considered by all the relevant qpid devs.
> 
> 2. Please don't do it this way. We have absolutely avoided using
> #ifdef
> when not essential. And I think you'll find that they are very rarely
> essential. The way we do this in the qpid C++ code is to have
> entirely
> separate Unix and Win32 implementations in different files and only
> link
> one of the files for a given platform.
> 
> Whatever you think of this strategy, and it has some downsides, that
> is
> the way we do it.
> 
> Offending part of the patch below.
> 
> [Sent to qpid dev list, to make this last point there]
> 
> Andrew
> 
> 
> ---
> a/qpid-cpp-mrg-0.7.904602/cpp/src/qmf/engine/ResilientConnection.cpp
> +++
> b/qpid-cpp-mrg-0.7.904602/cpp/src/qmf/engine/ResilientConnection.cpp
> @@ -39,8 +39,15 @@
>  #include <set>
>  #include <boost/intrusive_ptr.hpp>
>  #include <boost/noncopyable.hpp>
> -#include <unistd.h>
>  #include <fcntl.h>
> +#ifndef WIN32
> +       #include <unistd.h>
> +#else 
> +       #include <io.h>
> +       #include <winsock2.h>
> +       #define write _write
> +#endif
> +
>  
>  using namespace std;
>  using namespace qmf::engine;
> @@ -333,8 +340,13 @@ void ResilientConnectionImpl::setNotifyFd(int
> fd)
>  {
>      notifyFd = fd;
>      if (notifyFd > 0) {
> +#ifndef WIN32
>          int original = fcntl(notifyFd, F_GETFL);
>          fcntl(notifyFd, F_SETFL, O_NONBLOCK | original);
> +#else
> +               u_long iMode=1;
> +               ioctlsocket(notifyFd, FIONBIO, &iMode);
> +#endif
>      }
>  }
>  
> 
> 
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org