This patch checks that various callbacks are defined
appropriately. The callbacks are set in saMsgInitialize and stored in
the msgInstance. When a library call is made that we know will need to
use one of the callbacks (as determined by async calls, certain
combinations of flags, etc.) we must check that the callback is
defined. If not, return SA_AIS_ERR_INIT.

Index: lib/msg.c
===================================================================
--- lib/msg.c   (revision 1766)
+++ lib/msg.c   (working copy)
@@ -426,6 +426,13 @@
                goto error_exit;
        }
 
+       if ((openFlags & SA_MSG_QUEUE_RECEIVE_CALLBACK) &&
+           (msgInstance->callbacks.saMsgMessageReceivedCallback == NULL))
+       {
+               error = SA_AIS_ERR_INIT;
+               goto error_exit;
+       }
+
        error = saHandleCreate (&queueHandleDatabase,
                sizeof (struct queueInstance), queueHandle);
        if (error != SA_AIS_OK) {
@@ -537,6 +544,17 @@
                goto error_exit;
        }
 
+       if ((openFlags & SA_MSG_QUEUE_RECEIVE_CALLBACK) &&
+           (msgInstance->callbacks.saMsgMessageReceivedCallback == NULL)) {
+               error = SA_AIS_ERR_INIT;
+               goto error_put;
+       }
+
+       if (msgInstance->callbacks.saMsgQueueOpenCallback == NULL) {
+               error = SA_AIS_ERR_INIT;
+               goto error_put;
+       }
+
        error = saHandleCreate (&queueHandleDatabase,
                sizeof (struct queueInstance), &queueHandle);
        if (error != SA_AIS_OK) {
@@ -1134,13 +1152,15 @@
        printf ("[DEBUG]: saMsgQueueGroupTrack\n");
 
        if (queueGroupName == NULL) {
-               return (SA_AIS_ERR_INVALID_PARAM);
+               error = SA_AIS_ERR_INVALID_PARAM;
+               goto error_exit;
        }
 
        if ((notificationBuffer != NULL) &&
            (notificationBuffer->notification != NULL) &&
            (notificationBuffer->numberOfItems == 0)) {
-               return (SA_AIS_ERR_INVALID_PARAM);
+               error = SA_AIS_ERR_INVALID_PARAM;
+               goto error_exit;
        }
 
        if ((notificationBuffer != NULL) &&
@@ -1150,7 +1170,8 @@
 
        if ((trackFlags & SA_TRACK_CHANGES) &&
            (trackFlags & SA_TRACK_CHANGES_ONLY)) {
-               return (SA_AIS_ERR_BAD_FLAGS);
+               error = SA_AIS_ERR_BAD_FLAGS;
+               goto error_exit;
        }
 
        error = saHandleInstanceGet (&msgHandleDatabase, msgHandle,
@@ -1159,6 +1180,13 @@
                goto error_exit;
        }
 
+       if ((trackFlags == SA_TRACK_CURRENT) && (notificationBuffer != NULL) &&
+           (msgInstance->callbacks.saMsgQueueGroupTrackCallback == NULL))
+       {
+               error = SA_AIS_ERR_INIT;
+               goto error_put;
+       }
+
        /* DEBUG */
        printf ("[DEBUG]:\t group = %s\n",
                (char *)(queueGroupName->value));
@@ -1431,6 +1459,13 @@
                goto error_exit;
        }
 
+       if ((ackFlags & SA_MSG_MESSAGE_DELIVERED_ACK) &&
+           (msgInstance->callbacks.saMsgMessageDeliveredCallback == NULL))
+       {
+               error = SA_AIS_ERR_INIT;
+               goto error_exit;
+       }
+
        /* DEBUG */
        printf ("[DEBUG]:\t destination = %s\n",
                (char *)(destination->value));
@@ -1842,6 +1877,13 @@
                goto error_exit;
        }
 
+       if ((ackFlags & SA_MSG_MESSAGE_DELIVERED_ACK) &&
+           (msgInstance->callbacks.saMsgMessageDeliveredCallback == NULL))
+       {
+               error = SA_AIS_ERR_INIT;
+               goto error_exit;
+       }
+
        /* DEBUG */
        printf ("[DEBUG]:\t senderId = %llx\n", (unsigned long 
long)(*senderId));
 
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to