Обсуждение: SunOS patches

Поиск
Список
Период
Сортировка

SunOS patches

От
t-ishii@sra.co.jp
Дата:
Included are patches for SunOS port based on the Feb 24 snapshot.
Remaining problems are some minor compiling errors of ecpg and strange
NOTICE messages from initdb (known bug?).  I have tested the patches
on FreeBSD and Solairs2.6 to make sure they do not break other ports.

o added SunOS support to template/.similar

o changed UNIXSOCK_PATH macro in include/libpq/pqcomm.h. The macro
supposes sprintf() return the length of the result
string. Unfortunately on some platforms such as SunOS sprintf() never
returns value (I guess that behavior was inherited from BSD4.2). So I
changed in more portable way using strlen().

o changed backend/libpq/pqcomm.c. It uses atexit() to unlink an Unix
domain socket when postmaster exits. Again unfortunately SunOS does
not have it. Looking for an alternative, I found a general exiting
callback manager called on_exitpg() has already existed in PostgreSQL!
So I replaced atexit() with on_exitpg().

Tatsuo Ishii
t-ishii@sra.co.jp
----------------------------------------------------------------
*** template/.similar.orig    Wed Feb 25 10:00:55 1998
--- template/.similar    Wed Feb 25 10:03:02 1998
***************
*** 20,22 ****
--- 20,26 ----
  powerpc-unknown-linux-gnu=linux-elf
  sparc-sun-solaris=sparc_solaris-gcc
  sparc-unknown-linux-gnu=linux-elf-sparc
+ sparc-sun-sunos4.1.3=sunos4-gcc
+ sparc-sun-sunos4.1.3_JL=sunos4-gcc
+ sparc-sun-sunos4.1.4=sunos4-gcc
+ sparc-sun-sunos4.1.4_JL=sunos4-gcc
*** backend/libpq/pqcomm.c.orig    Wed Feb 25 10:04:28 1998
--- backend/libpq/pqcomm.c    Wed Feb 25 10:05:57 1998
***************
*** 645,651 ****
      if (family == AF_UNIX)
        {
          chmod(sock_path, 0777);
!         atexit(do_unlink);
        }
      return (STATUS_OK);
  }
--- 645,651 ----
      if (family == AF_UNIX)
        {
          chmod(sock_path, 0777);
!          on_exitpg(do_unlink,0);
        }
      return (STATUS_OK);
  }
*** include/libpq/pqcomm.h.orig    Wed Feb 25 10:07:25 1998
--- include/libpq/pqcomm.h    Wed Feb 25 10:07:41 1998
***************
*** 34,41 ****
  /* Configure the UNIX socket address for the well known port. */

  #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
--- 34,41 ----
  /* Configure the UNIX socket address for the well known port. */

  #define    UNIXSOCK_PATH(sun,port) \
!     (sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)), \
!      strlen((sun).sun_path)+ 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

Re: [HACKERS] SunOS patches

От
t-ishii@sra.co.jp
Дата:
>o changed backend/libpq/pqcomm.c. It uses atexit() to unlink an Unix
>domain socket when postmaster exits. Again unfortunately SunOS does
>not have it. Looking for an alternative, I found a general exiting
>callback manager called on_exitpg() has already existed in PostgreSQL!
>So I replaced atexit() with on_exitpg().

I found my previous patches for backend/libpq/pqcomm.c did not work if
backend crashed accidentaly (yes, I found yet another SQL commands to
crash the backend, but it's an another story). If the backend dies
abnormally (SEGFALUT etc.)  postmaster calls functions registered by
on_exitpg(). This is ok. Problem is postmaster does not exits in that
case and leaves the socket file with link counter 0! Too bad. It seems
the only solution that would work with both SunOS and other platforms
is let exitpg() call do_unlink() in backend/libpq/pqcomm.c (note that
exitpg() is the only function calling exit()).

included are patches for Feb 26 snapshot. I hope these are the last
patches for SunOS port:-)

P.S. I didn't see my patches to tempalte/.similar in Mar 1
snapshot. Should I repost the patches?
---
Tatsuo Ishii
t-ishii@sra.co.jp
----------------------------------------------------------------------
*** backend/libpq/pqcomm.c.orig    Fri Feb 27 14:07:52 1998
--- backend/libpq/pqcomm.c    Fri Feb 27 14:08:50 1998
***************
*** 564,571 ****
   * Shutdown routine for backend connection
   * If a Unix socket is used for communication, explicitly close it.
   */
! static void
! do_unlink()
  {
      if (sock_path[0])
          unlink(sock_path);
--- 564,571 ----
   * Shutdown routine for backend connection
   * If a Unix socket is used for communication, explicitly close it.
   */
! void
! StreamDoUnlink()
  {
      if (sock_path[0])
          unlink(sock_path);
***************
*** 645,651 ****
      if (family == AF_UNIX)
      {
          chmod(sock_path, 0777);
-         atexit(do_unlink);
      }
      return (STATUS_OK);
  }
--- 645,650 ----
*** backend/storage/ipc/ipc.c.orig    Fri Feb 27 14:09:12 1998
--- backend/storage/ipc/ipc.c    Fri Feb 27 14:09:26 1998
***************
*** 136,141 ****
--- 136,142 ----
      for (i = onexit_index - 1; i >= 0; --i)
          (*onexit_list[i].function) (code, onexit_list[i].arg);

+      StreamDoUnlink();
      exit(code);
  }


Re: [HACKERS] SunOS patches

От
The Hermit Hacker
Дата:
On Mon, 2 Mar 1998 t-ishii@sra.co.jp wrote:

>
> included are patches for Feb 26 snapshot. I hope these are the last
> patches for SunOS port:-)

    Ack!

> P.S. I didn't see my patches to tempalte/.similar in Mar 1
> snapshot. Should I repost the patches?
> ---
> Tatsuo Ishii
> t-ishii@sra.co.jp
> ----------------------------------------------------------------------
> *** backend/libpq/pqcomm.c.orig    Fri Feb 27 14:07:52 1998
> --- backend/libpq/pqcomm.c    Fri Feb 27 14:08:50 1998
> ***************
> *** 564,571 ****
>    * Shutdown routine for backend connection
>    * If a Unix socket is used for communication, explicitly close it.
>    */
> ! static void
> ! do_unlink()
>   {
>       if (sock_path[0])
>           unlink(sock_path);
> --- 564,571 ----
>    * Shutdown routine for backend connection
>    * If a Unix socket is used for communication, explicitly close it.
>    */
> ! void
> ! StreamDoUnlink()


    What breaks by renaming this function?? :(

Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org


Re: [HACKERS] SunOS patches

От
t-ishii@sra.co.jp
Дата:
>> ----------------------------------------------------------------------
>> *** backend/libpq/pqcomm.c.orig    Fri Feb 27 14:07:52 1998
>> --- backend/libpq/pqcomm.c    Fri Feb 27 14:08:50 1998
>> ***************
>> *** 564,571 ****
>>    * Shutdown routine for backend connection
>>    * If a Unix socket is used for communication, explicitly close it.
>>    */
>> ! static void
>> ! do_unlink()
>>   {
>>       if (sock_path[0])
>>           unlink(sock_path);
>> --- 564,571 ----
>>    * Shutdown routine for backend connection
>>    * If a Unix socket is used for communication, explicitly close it.
>>    */
>> ! void
>> ! StreamDoUnlink()
>
>
>    What breaks by renaming this function?? :(

Nothing. do_unlink() is called only from line 648 and the line was
deleted by my patches.
Just removing "static" from the declaration of do_unlink might be ok.
However function name "do_unlink" would be too general IMHO.
--
Tatsuo Ishii
t-ishii@sra.co.jp

Re: [HACKERS] SunOS patches

От
"Thomas G. Lockhart"
Дата:
The Hermit Hacker wrote:

> On Mon, 2 Mar 1998 t-ishii@sra.co.jp wrote:
>
> >
> > included are patches for Feb 26 snapshot. I hope these are the last
> > patches for SunOS port:-)
>
>         Ack!
>
> > P.S. I didn't see my patches to tempalte/.similar in Mar 1
> > snapshot. Should I repost the patches?
> > ---
> > Tatsuo Ishii
> > t-ishii@sra.co.jp
> > ----------------------------------------------------------------------
> > *** backend/libpq/pqcomm.c.orig       Fri Feb 27 14:07:52 1998
> > --- backend/libpq/pqcomm.c    Fri Feb 27 14:08:50 1998
> > ***************
> > *** 564,571 ****
> >    * Shutdown routine for backend connection
> >    * If a Unix socket is used for communication, explicitly close it.
> >    */
> > ! static void
> > ! do_unlink()
> >   {
> >       if (sock_path[0])
> >               unlink(sock_path);
> > --- 564,571 ----
> >    * Shutdown routine for backend connection
> >    * If a Unix socket is used for communication, explicitly close it.
> >    */
> > ! void
> > ! StreamDoUnlink()
>
>         What breaks by renaming this function?? :(

On my linux box:

...
gcc -I../../include -I../../backend -I/usr/include/ncurses
-I/usr/include/readline -O2   -m486 -Wall -Wmissing-prototypes -I..    -c
pqcomm.c -o pqcomm.o
pqcomm.c:569: warning: no previous prototype for `StreamDoUnlink'
...
ipc.c: In function `exitpg':
ipc.c:139: warning: implicit declaration of function `StreamDoUnlink'

Seems to run OK though. Would like to get the warnings out of there for a
release. I didn't pay attention to Tatsuo's earlier patches since they didn't
directly affect my platform; where would these things be declared? Can Tatsuo
come up with a few more patches to fix this up? It would be worth waiting a few
hours on the release to get SunOS in there (the docs claim it is supported :)

                                                  - Tom


Re: [HACKERS] SunOS patches

От
The Hermit Hacker
Дата:
On Mon, 2 Mar 1998, Thomas G. Lockhart wrote:

> gcc -I../../include -I../../backend -I/usr/include/ncurses
> -I/usr/include/readline -O2   -m486 -Wall -Wmissing-prototypes -I..    -c
> pqcomm.c -o pqcomm.o
> pqcomm.c:569: warning: no previous prototype for `StreamDoUnlink'
> ...
> ipc.c: In function `exitpg':
> ipc.c:139: warning: implicit declaration of function `StreamDoUnlink'
>
> Seems to run OK though. Would like to get the warnings out of there for a
> release. I didn't pay attention to Tatsuo's earlier patches since they didn't
> directly affect my platform; where would these things be declared? Can Tatsuo
> come up with a few more patches to fix this up? It would be worth waiting a few
> hours on the release to get SunOS in there (the docs claim it is supported :)

    What he said... :)

    Tatsuo...could you send me a clean patch that fixes the above and
includes the last patch?  I'll end up scrutinizing it in the morning, most
likely, before applying it, but it would be nice to get it in before I
bundle things...

    As long as I'm confident that it won't affect anything or anyone
else :)


Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org


Re: [HACKERS] SunOS patches

От
t-ishii@sra.co.jp
Дата:
>On Mon, 2 Mar 1998, Thomas G. Lockhart wrote:
>
>> gcc -I../../include -I../../backend -I/usr/include/ncurses
>> -I/usr/include/readline -O2   -m486 -Wall -Wmissing-prototypes -I..    -c
>> pqcomm.c -o pqcomm.o
>> pqcomm.c:569: warning: no previous prototype for `StreamDoUnlink'
>> ...
>> ipc.c: In function `exitpg':
>> ipc.c:139: warning: implicit declaration of function `StreamDoUnlink'
>>
>> Seems to run OK though. Would like to get the warnings out of there for a
>> release. I didn't pay attention to Tatsuo's earlier patches since they didn't
>> directly affect my platform; where would these things be declared? Can Tatsuo
>> come up with a few more patches to fix this up? It would be worth waiting a few
>> hours on the release to get SunOS in there (the docs claim it is supported :)
>
>    What he said... :)
>
>    Tatsuo...could you send me a clean patch that fixes the above and
>includes the last patch?  I'll end up scrutinizing it in the morning, most
>likely, before applying it, but it would be nice to get it in before I
>bundle things...
>
>    As long as I'm confident that it won't affect anything or anyone
>else :)

Please give me an hour. I will work on this now.
--
Tatsuo Ishii
t-ishii@sra.co.jp

Re: [HACKERS] SunOS patches

От
t-ishii@sra.co.jp
Дата:
>>On Mon, 2 Mar 1998, Thomas G. Lockhart wrote:
>>
>>> gcc -I../../include -I../../backend -I/usr/include/ncurses
>>> -I/usr/include/readline -O2   -m486 -Wall -Wmissing-prototypes -I..    -c
>>> pqcomm.c -o pqcomm.o
>>> pqcomm.c:569: warning: no previous prototype for `StreamDoUnlink'
>>> ...
>>> ipc.c: In function `exitpg':
>>> ipc.c:139: warning: implicit declaration of function `StreamDoUnlink'
>>>
>>> Seems to run OK though. Would like to get the warnings out of there for a
>>> release. I didn't pay attention to Tatsuo's earlier patches since they didn't
>>> directly affect my platform; where would these things be declared? Can Tatsuo
>>> come up with a few more patches to fix this up? It would be worth waiting a few
>>> hours on the release to get SunOS in there (the docs claim it is supported :)
>>
>>    What he said... :)
>>
>>    Tatsuo...could you send me a clean patch that fixes the above and
>>includes the last patch?  I'll end up scrutinizing it in the morning, most
>>likely, before applying it, but it would be nice to get it in before I
>>bundle things...
>>
>>    As long as I'm confident that it won't affect anything or anyone
>>else :)
>
>Please give me an hour. I will work on this now.

Here it is.
(Mar 1 snapshot seems to lack the pacthes to include/libpq/pqcomm.h. so
I included that also.)

----------------------------- cut here -----------------------------
*** include/libpq/libpq.h.orig    Thu Feb 26 17:02:21 1998
--- include/libpq/libpq.h    Mon Mar  2 13:16:06 1998
***************
*** 282,286 ****
--- 282,287 ----
  extern int    StreamServerPort(char *hostName, short portName, int *fdP);
  extern int    StreamConnection(int server_fd, Port *port);
  extern void StreamClose(int sock);
+ extern void StreamDoUnlink(void);

  #endif                            /* LIBPQ_H */
*** include/libpq/pqcomm.h.orig    Mon Mar  2 13:55:19 1998
--- include/libpq/pqcomm.h    Mon Mar  2 13:57:10 1998
***************
*** 35,42 ****
  /* Configure the UNIX socket address for the well known port. */

  #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
--- 35,43 ----
  /* Configure the UNIX socket address for the well known port. */

  #define UNIXSOCK_PATH(sun,port) \
!      (sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)), \
!       strlen((sun).sun_path)+ 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
*** backend/libpq/pqcomm.c.orig    Thu Feb 26 17:01:05 1998
--- backend/libpq/pqcomm.c    Mon Mar  2 13:16:06 1998
***************
*** 564,571 ****
   * Shutdown routine for backend connection
   * If a Unix socket is used for communication, explicitly close it.
   */
! static void
! do_unlink()
  {
      if (sock_path[0])
          unlink(sock_path);
--- 564,571 ----
   * Shutdown routine for backend connection
   * If a Unix socket is used for communication, explicitly close it.
   */
! void
! StreamDoUnlink()
  {
      if (sock_path[0])
          unlink(sock_path);
***************
*** 645,651 ****
      if (family == AF_UNIX)
      {
          chmod(sock_path, 0777);
-         atexit(do_unlink);
      }
      return (STATUS_OK);
  }
--- 645,650 ----
*** backend/storage/ipc/ipc.c.orig    Thu Feb 26 17:01:36 1998
--- backend/storage/ipc/ipc.c    Mon Mar  2 13:16:06 1998
***************
*** 38,43 ****
--- 38,44 ----
  #include <sys/sem.h>
  #include <sys/shm.h>
  #include "utils/memutils.h"
+ #include "libpq/libpq.h"

  #if defined(sparc_solaris)
  #include <string.h>
***************
*** 136,141 ****
--- 137,143 ----
      for (i = onexit_index - 1; i >= 0; --i)
          (*onexit_list[i].function) (code, onexit_list[i].arg);

+      StreamDoUnlink();
      exit(code);
  }


Re: [HACKERS] SunOS patches

От
The Hermit Hacker
Дата:
On Mon, 2 Mar 1998 t-ishii@sra.co.jp wrote:

> Here it is.
> (Mar 1 snapshot seems to lack the pacthes to include/libpq/pqcomm.h. so
> I included that also.)

    Okay, applied...I'll test it under solaris tomorrow before I
package things up, and FreeBSD tonight...everyone else should do a run
though quickly also...


Marc G. Fournier
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org