Questions regarding notify processing.

Поиск
Список
Период
Сортировка
От Terry Lee Tucker
Тема Questions regarding notify processing.
Дата
Msg-id 200502241113.43442.terry@esc1.com
обсуждение исходный текст
Ответы Re: Questions regarding notify processing.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hello List:

I am working on the proper method for Notification processing. The application
interface is X-Windows and I am using the database socket as an alternate
input source to the X-Server. I have a callback that fires when there is data
to read on the socket. Here is the setup:

/* This callback fires when there is data to read on the database socket. */
void DbInputCB (XtPointer clientData, int *source, XtInputId *id)
{
    .
    .
    CheckForNotifies (ctrl);
    .
    .
    .
}

/* This function processes NOTIFY messages. */
void CheckForNotifies (Controls *ctrl)
{
   PQflush (ctrl->sys->conn);              // always flush it first ;o)

    PQconsumeInput (ctrl->sys->conn);       // suck up queued input
    while ((ctrl->notify = PQnotifies (ctrl->sys->conn)) != NULL)
    {
        /* If you are interested in receiving any NOTICE data, you will
         * have to have this function defined locally. */
        if (ctrl->main->backEndNotify)
        {
            void (*p) () = (void *) ctrl->main->backEndNotify;
            (*p) (ctrl);                    // call the function
        }
        PQfreemem (ctrl->notify);           // free the memory
    }
}

All this works great except for certain cases where one of the notify
messages, the one I'm really interested in, gets spooled, queued, or
something and is not delivered until I send another notification, after the
fact, from another client; then, I finally get the message delivered along
with the one I just sent. I have a certain interface that registers an
interest in APPT_MADE. I have a trigger that, when the final appointment is
made, issues a NOTIFY for those interested. The operation that created the
appointment is performed as an Asynchronous command with PQsendQuery due to
the fact that there may be two sql commands in the sql string, depending on
what the user does. The interface allows editing of two different tables
simultaneously. The message sent by the trigger fired as a result of the
update does not get delivered unless I send another notify, then, it is
delivered, along with the one I just sent. I tried calling CheckForNotifies()
from the interface code after the save operation, but then, after two back to
back updates, or sometimes just one, the PQsendQuery call hangs up. The only
way to "unhang it" is to issue a NOTIFY from another client, which allows
PQsendQuery to continue.

Obviously, something is blocking. Also, I don't understand why the APPT_MADE
message does not get delivered. Any pointers would be appreciated.

Thanks...

В списке pgsql-general по дате отправления:

Предыдущее
От: Shelby Cain
Дата:
Сообщение: Re: stats collector appears to be dying
Следующее
От: Alexis Vasquez
Дата:
Сообщение: Unsuscribe