Search Postgresql Archives

Questions regarding notify processing.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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...

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux