Обсуждение: Have BackendXidGetPid return pid_t

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

Have BackendXidGetPid return pid_t

От
Sami Imseih
Дата:
Hi,

While looking at something nearby, I noticed that BackendXidGetPid()
uses an "int" for "pid", where it should be used "pid_t" like in other
places in the code including in procarray.c.

Here is a small patch to fix this.


Thanks,

--
Sami Imseih
Amazon Web Services (AWS)

Вложения

Re: Have BackendXidGetPid return pid_t

От
Tom Lane
Дата:
Sami Imseih <samimseih@gmail.com> writes:
> While looking at something nearby, I noticed that BackendXidGetPid()
> uses an "int" for "pid", where it should be used "pid_t" like in other
> places in the code including in procarray.c.

I don't think this is an amazingly good idea, considering that the
value it's returning is from an "int" field in struct PGPROC.
You didn't change the function's "result" variable either, nor
is it clear what callers like

                        snprintf(buf, NCHARS, "%d",
                                 BackendXidGetPid(members[j].xid));

should be doing.

Perhaps at some point we should try to uniformly represent PIDs
as pid_t, but it'll require a far larger patch than this.

(I have a vague recollection also that some places expect PIDs in
shared memory to be atomically updatable, so machines where pid_t
is actually different from int might start to have issues.)

            regards, tom lane