Re: Dynamic Shared Memory stuff

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Dynamic Shared Memory stuff
Date: 2014-04-12 05:32:03
Message-ID: CAA4eK1L548P=0ZNMnG+3cebjem-rHfZ80JnvFd4pqwhUxnFoxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Apr 9, 2014 at 9:20 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Wed, Apr 9, 2014 at 7:41 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>> I am just not sure whether it is okay to rearrange the code and call
>> GetLastError() only if returned handle is Invalid (NULL) or try to look
>> for more info.
>
> Well, I don't know either. You wrote the Windows portion of this
> code, so you'll have to decide what's best. If the best practice in
> this area is to only call GetLastError() if the handle isn't valid,
> then that's probably what we should do, too. But I can't speak to
> what the best practice is.

I have checked that other place in code also check handle to
decide if API has failed. Refer function PGSharedMemoryIsInUse().
So I think fix to call GetLastError() after checking handle is okay.
Attached patch fixes this issue. After patch, the server shows below
log which is exactly what is expected from test_shm_mq

LOG: registering background worker "test_shm_mq"
LOG: starting background worker process "test_shm_mq"
LOG: worker process: test_shm_mq (PID 4888) exited with exit code 1
LOG: unregistering background worker "test_shm_mq"
LOG: registering background worker "test_shm_mq"
LOG: starting background worker process "test_shm_mq"
LOG: worker process: test_shm_mq (PID 3128) exited with exit code 1
LOG: unregistering background worker "test_shm_mq"

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
fix_dsm_invalid_errcode_issue.patch application/octet-stream 1.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Christian Ullrich 2014-04-12 07:06:08 Re: PostgreSQL in Windows console and Ctrl-C
Previous Message Amit Kapila 2014-04-12 04:05:49 Re: PostgreSQL in Windows console and Ctrl-C