Re: Global variables in exec()

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Global variables in exec()
Date: 2003-05-06 15:21:37
Message-ID: 200305061521.h46FLbO23513@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > -
> > - typedef uint32 IpcMemoryKey; /* shared memory key passed to shmget(2) */
>
> IpcMemoryKey is a SysV-specific typedef and has *no* business being
> moved out of the sysv-specific port file. Once again I urge you to
> consider making a Windows-specific shmem port file, instead of tromping
> all over the Unix code in order to support an API that Windows doesn't
> like in the first place :-(

I don't have the time or experience to do a Win32-specific shared memory
implementation. PeerDirect used a SysV emulation file, and that is what
I am using. Also, I want Unix to support fork/exec so we can test any
fork/exec problems in Unix, so I will need that parameter to be passed
anyway for Unix.

We only support one shared memory implementation right now, but if we
add another, we can modify this code to abstract out that data type.

All the ExecBackend stuff is marked so it will be easy to modify later.

> > ! /* database name at the end because it might contain commas */
> > ! sprintf(pbuf, "%d,%d,%s", port->sock, UsedShmemSegID, port->database_name);
>
> snprintf please. I don't think there's any guaranteed limit on the size
> of port->database_name these days.

OK, fixed to snprintf. I did define pbuf as:

+ char pbuf[NAMEDATALEN + 256];

becuase I assume a database name can't be more than NAMEDATALEN. The
256 is for the other integers passed.

> > + sscanf(optarg, "%d,%d,", &MyProcPort->sock, &UsedShmemSegID);
> > + DBName = strdup(strrchr(optarg, ',') + 1);
>
> What happens when the dbname contains a comma?

Oops, good catch. I was careful to put the database name at the end to
handle such cases, but forgot it here.

Here is a new patch that adds the shared memory param for bootstrap.
PeerDirect only passed GUC and the two values of socket file descriptor
and shared memory id on the command line, so I have all those covered
now.

At the same time, I modified bootstrap's -p parameter to take the
database name as a parameter just like the ordinary backend -p does.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 9.2 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-05-06 23:35:09 Re: Global variables in exec()
Previous Message Tom Lane 2003-05-06 05:28:17 Re: Global variables in exec()