Thread

  1. Snapshot 270198 compile error

    Serj <fenix@am.ring.ru> — 1998-01-27T08:49:33Z

    On linux-elf:
    
    
    pqcomm.c: In function `StreamServerPort':
    pqcomm.c:605: structure has no member named `sun_len'
    pqcomm.c: In function `StreamOpen':
    pqcomm.c:760: structure has no member named `sun_len'
    ___
     
    SY, Serj
    
    
  2. Re: [HACKERS] Snapshot 270198 compile error

    Goran Thyni <goran@bildbasen.se> — 1998-01-27T10:08:33Z

       On linux-elf:
       pqcomm.c: In function `StreamServerPort':
       pqcomm.c:605: structure has no member named `sun_len'
       pqcomm.c: In function `StreamOpen':
       pqcomm.c:760: structure has no member named `sun_len'
    
    Yes,
    the sun_len member of struct sockaddr_un is BSD-specific.
    It is not there in Linux, nor in a SVR4-system we run here.
    
    I had hard-coded the extra offset to 1 in the UNIXSOCK_PATH macro, 
    maybe 2 or 4 works OK on all systems.
    
          regards,
    -- 
    ---------------------------------------------
    Gran Thyni, sysadm, JMS Bildbasen, Kiruna
    
    
    
  3. Re: [HACKERS] Snapshot 270198 compile error

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-01-27T12:37:07Z

    > 
    > 
    >    On linux-elf:
    >    pqcomm.c: In function `StreamServerPort':
    >    pqcomm.c:605: structure has no member named `sun_len'
    >    pqcomm.c: In function `StreamOpen':
    >    pqcomm.c:760: structure has no member named `sun_len'
    > 
    > Yes,
    > the sun_len member of struct sockaddr_un is BSD-specific.
    > It is not there in Linux, nor in a SVR4-system we run here.
    > 
    > I had hard-coded the extra offset to 1 in the UNIXSOCK_PATH macro, 
    > maybe 2 or 4 works OK on all systems.
    
    Gee, thanks.  This does help tremendously.  The protocol overhaul person
    did not have the sun_len field, thought the +1 as a mistake of counting
    the trailing null and removed it.  I will apply the following patch
    which should fix the situation.  One problem is that under BSD, we never
    set the sun_len field, but it still seems to work, and I can't think of
    a platform-safe way of doing the assignment, so I will leave it alone.
    
    ---------------------------------------------------------------------------
    
    *** ./include/libpq/pqcomm.h.orig	Tue Jan 27 07:25:25 1998
    --- ./include/libpq/pqcomm.h	Tue Jan 27 07:36:34 1998
    ***************
    *** 35,42 ****
      
      #define	UNIXSOCK_PATH(sun,port) \
      	(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
    ! 		sizeof ((sun).sun_len) + sizeof ((sun).sun_family))
    ! 
      
      /*
       * These manipulate the frontend/backend protocol version number.
    --- 35,46 ----
      
      #define	UNIXSOCK_PATH(sun,port) \
      	(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
    ! 		+ 1 + sizeof ((sun).sun_family))
    ! /*
    !  *		+ 1 is for BSD-specific sizeof((sun).sun_len)
    !  *		We never actually set sun_len, and I can't think of a
    !  *		platform-safe way of doing it, but the code still works. bjm
    !  */
      
      /*
       * These manipulate the frontend/backend protocol version number.
    
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us
    
    
  4. Re: [HACKERS] Snapshot 270198 compile error

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-01-27T15:35:28Z

    > 
    > 
    >    On linux-elf:
    >    pqcomm.c: In function `StreamServerPort':
    >    pqcomm.c:605: structure has no member named `sun_len'
    >    pqcomm.c: In function `StreamOpen':
    >    pqcomm.c:760: structure has no member named `sun_len'
    > 
    > Yes,
    > the sun_len member of struct sockaddr_un is BSD-specific.
    > It is not there in Linux, nor in a SVR4-system we run here.
    > 
    > I had hard-coded the extra offset to 1 in the UNIXSOCK_PATH macro, 
    > maybe 2 or 4 works OK on all systems.
    
    I have applied a patch to document the +1 in the socket length.
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us
    
    
  5. Re: [HACKERS] Snapshot 270198 compile error

    Phil Thompson <phil@river-bank.demon.co.uk> — 1998-01-27T19:25:11Z

    Bruce Momjian wrote:
    
    >   #define       UNIXSOCK_PATH(sun,port) \
    >         (sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
    > !               + 1 + sizeof ((sun).sun_family))
    > ! /*
    > !  *            + 1 is for BSD-specific sizeof((sun).sun_len)
    > !  *            We never actually set sun_len, and I can't think of a
    > !  *            platform-safe way of doing it, but the code still works. bjm
    > !  */
    
    I don't think this is going to work.  On glibc2 you will end up with a
    trailing '\0' in the socket name.  You won't be able to see it but I
    think it will be there.  Is the following version portable?
    
    #define	UNIXSOCK_PATH(sun,port) \
    	(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
    	((char *)&(sun).sun_path[0] - (char *)&(sun)))
    
    Phil
    
    
  6. Re: [HACKERS] Snapshot 270198 compile error

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-01-27T19:50:01Z

    > 
    > Bruce Momjian wrote:
    > 
    > >   #define       UNIXSOCK_PATH(sun,port) \
    > >         (sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
    > > !               + 1 + sizeof ((sun).sun_family))
    > > ! /*
    > > !  *            + 1 is for BSD-specific sizeof((sun).sun_len)
    > > !  *            We never actually set sun_len, and I can't think of a
    > > !  *            platform-safe way of doing it, but the code still works. bjm
    > > !  */
    
    OK, I am with you.  Even better, let's use offset().  Takes care of
    possible OS padding between fields too:
    
    ---------------------------------------------------------------------------
    
    
    *** ./include/libpq/pqcomm.h.orig	Tue Jan 27 14:28:27 1998
    --- ./include/libpq/pqcomm.h	Tue Jan 27 14:48:15 1998
    ***************
    *** 35,44 ****
      
      #define	UNIXSOCK_PATH(sun,port) \
      	(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
    ! 		+ 1 + sizeof ((sun).sun_family))
      /*
    !  *		+ 1 is for BSD-specific sizeof((sun).sun_len)
    !  *		We never actually set sun_len, and I can't think of a
       *		platform-safe way of doing it, but the code still works. bjm
       */
      
    --- 35,44 ----
      
      #define	UNIXSOCK_PATH(sun,port) \
      	(sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)) + \
    ! 		offsetof(struct sockaddr_un, sun_path))
      /*
    !  *		We do this because sun_len is in BSD's struct, while others don't.
    !  *		We never actually set BSD's sun_len, and I can't think of a
       *		platform-safe way of doing it, but the code still works. bjm
       */
      
    
    
    -- 
    Bruce Momjian
    maillist@candle.pha.pa.us