Re: PostgreSQL X/Open Socket / BSD Socket Issue on HP-UX

From: MUHAMMAD ASIF <anaeem(dot)it(at)hotmail(dot)com>
To: <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PostgreSQL X/Open Socket / BSD Socket Issue on HP-UX
Date: 2011-09-22 10:51:11
Message-ID: BAY164-W55AF2AFC937E1D3C5B488BFF0C0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Very sorry for late reply.
You are right, _xpg_ socket functionality is not available in older systems, it is available in hp-ux 11.23 version through patch HCO_35744 . HPUX 10.20 is very old machine (1996). I am using latest HPUX B.11.31 machine, I don't have access to older systems. -D_XOPEN_SOURCE_EXTENDED make the postgres build X/Open Socket enabled including connector's i.e libpq. Now if system default 64bit perl (BSD Socket) try to use libpq (X/Open Socket) it will end up in unexpected results or errors . HP-UX don't allow mixing of X/Open Socket objects and BSD Socket objects in the same 64bit binary, HP tried to fix this issue through -D_HPUX_ALT_XOPEN_SOCKET_API on later version of OS. It seems nice that if postgres adopt this fix at least for connectors (PFA patch, minor change in src/interfaces/libpq/Makefile) and so that users on later hp-ux boxes don't trouble with these socket issues  and connect their applications to database server with the help of libpq without the fear of X/Open Socket or BSD Socket complexity. On older system defining _HPUX_ALT_XOPEN_SOCKET_API should do no effects or issues. Thanks.
http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/xopen_networking.7.html )..................
HP-UX provides two styles of Sockets API:
    - default BSD Sockets    -X/Open Sockets
These two styles of Sockets API have the same function names but they have differences in semantics and argument types. For example, the optlen field in X/Open getsockopt() is size_t type, while BSD getsockopt() is int type. In 64 bit mode, size_t is 64 bit and int is still 32 bit.
Linking objects compiled to X/Open Sockets specification and objects compiled to BSD Sockets specification in the same program using the linkage method in method A would erroneously resolve BSD Sockets calls to X/Open Sockets functions in the Xnet library. As a result, the program may result in application core dumps or unexpected Socket errors when it is run. These symptoms commonly occur when BSD Sockets accept(), getpeername(), getsockname(), getsockopt(), recvfrom(), sendmsg(), and recvmsg() are called.
..................
Best Regards,Muhammad Asif Naeem

----------------------------------------
> To: anaeem(dot)it(at)hotmail(dot)com
> CC: pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] PostgreSQL X/Open Socket / BSD Socket Issue on HP-UX
> Date: Tue, 20 Sep 2011 18:06:55 -0400
> From: tgl(at)sss(dot)pgh(dot)pa(dot)us
>
> MUHAMMAD ASIF <anaeem(dot)it(at)hotmail(dot)com> writes:
> > I faced similar issue as discussed in "http://postgresql.1045698.n5.nabble.com/Fwd-DBD-Pg-on-HP-UX-11-31-64bit-td3305163.html".
> > (man xopen_networking - http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/xopen_networking.7.html) ... There are two ways to obtain X/Open Sockets functionality: * Method A is in compliance with X/Open compilation specification. * Method B slightly deviates from X/Open compilation specification. However, Method B allows a program to include both objects compiled to X/Open Sockets specification and objects compiled to BSD Sockets specification. ...
> > PostgreSQL support X/Open Sockets. Apache web server (2.2.15, /opt/hpws22/apache) and Perl (5.8.8, /opt/perl_64) are BSD Socket applications that are default with the OS. I tried Method B (It provides wrapper _xpg_ socket functions that allows using X/Open socket objects and BSD socket objects in the same binary) to build PostgreSQL 9.1 code, I LD_PRELOAD the generated libpq binary, without any other change both perl and apache work fine with postgresql now,and it is easy to implement too. We just need to build the source code with "-D_XOPEN_SOURCE=600 -D_HPUX_ALT_XOPEN_SOCKET_API" and link binary with libc. PFA patch. Thanks.
>
> AFAICT, the proposed patch will break things on at least some versions
> of HPUX. You can't just arbitrarily remove the reference to -lxnet,
> at least not without explaining to us why the existing comment about it
> is wrong. Likewise, removing -D_XOPEN_SOURCE_EXTENDED isn't
> acceptable without a whole more supporting evidence than you've
> provided. (I'm fairly certain that the latter will break the build on
> my old HPUX 10.20 box, for example.)
>
> regards, tom lane

Attachment Content-Type Size
hp-ux_socket.patch.v2 application/octet-stream 708 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2011-09-22 10:52:51 Re: WIP: SP-GiST, Space-Partitioned GiST
Previous Message Heikki Linnakangas 2011-09-22 10:05:33 Re: WIP: SP-GiST, Space-Partitioned GiST