[Openais] Fix for bug 782

Steven Dake sdake at mvista.com
Tue Jul 26 12:13:40 PDT 2005


On Tue, 2005-07-26 at 12:09 -0700, Mark Haverkamp wrote:
> On Tue, 2005-07-26 at 11:54 -0700, Steven Dake wrote:
> > Mark
> > 
> > I'm a little confused by why this patch returns SA_AIS_ERR_BAD_HANDLE.
> > 
> > The spec says that is only for bad handle objects, which is not the case
> > that is tested for in the patch.
> 
> Here is what I am using from page 46 line 7:
> 
> "SA_AIS_ERR_BAD_HANDLE - The handle eventHandle is invalid, due to one
> or more of the reasons below:
> • It is corrupted, 
> >> was not obtained via the saEvtEventDeliverCallback() function <<
> 
> , or saEvtEventFree() has already been invoked for eventHandle.
> • The corresponding event channel has already been closed.
> • The handle evtHandle that was passed to the saEvtChannelOpen() or
> saEvtChannelOpenAsync() functions has already been finalized."
> 
> 

Which one of the above cases applies?  It looks to me like it should
return ERR_ACCESS but I'm not convinced either way yet :)

regards
-steve


> > 
> > regards
> > -steve
> > 
> > On Tue, 2005-07-26 at 09:58 -0700, Mark Haverkamp wrote:
> > > Certain events may not be modified.  In particular event data received.
> > > The B spec says on page 41 line 31:
> > > 
> > > SA_AIS_ERR_ACCESS - The access to this event is denied. In particular, a subscriber
> > > is not allowed to modify an event delivered by the
> > > saEvtEventDeliverCallback() callback function
> > > 
> > > This patch creates a read only flag associated with an event.
> > > 
> > > Index: openais_work/lib/evt.c
> > > ===================================================================
> > > --- openais_work.orig/lib/evt.c	2005-07-25 09:49:46.000000000 -0700
> > > +++ openais_work/lib/evt.c	2005-07-25 10:00:50.000000000 -0700
> > > @@ -175,6 +175,7 @@
> > >   * edi_mutex:			event data mutex
> > >   * edi_hl:				pointer to channel's handle 
> > >   * 						struct for this event.
> > > + * edi_ro:				read only flag
> > >   */
> > >  struct event_data_instance {
> > >  	SaEvtChannelHandleT		edi_channel_handle;
> > > @@ -190,6 +191,7 @@
> > >  	int						edi_freeing;
> > >  	pthread_mutex_t			edi_mutex;
> > >  	struct handle_list		*edi_hl;
> > > +	int 					edi_ro;
> > >  };
> > >  
> > > 
> > > @@ -482,6 +484,7 @@
> > >  	memset(edi, 0, sizeof(*edi));
> > >  
> > >  	pthread_mutex_init(&edi->edi_mutex, NULL);
> > > +	edi->edi_ro = 1;
> > >  	edi->edi_freeing = 0;
> > >  	edi->edi_channel_handle = evt->led_lib_channel_handle;
> > >  	edi->edi_priority = evt->led_priority;
> > > @@ -1319,6 +1322,7 @@
> > >  	memset(edi, 0, sizeof(*edi));
> > >  
> > >  	pthread_mutex_init(&edi->edi_mutex, NULL);
> > > +	edi->edi_ro = 0;
> > >  	edi->edi_freeing = 0;
> > >  	edi->edi_channel_handle = channelHandle;
> > >  	edi->edi_pub_node = evti->ei_node_id;
> > > @@ -1412,6 +1416,14 @@
> > >  	}
> > >  	pthread_mutex_lock(&edi->edi_mutex);
> > >  
> > > +	/*
> > > +	 * Cannot modify an event returned via callback.
> > > +	 */
> > > +	if (edi->edi_ro) {
> > > +		error = SA_AIS_ERR_ACCESS;
> > > +		goto attr_set_unlock;
> > > +	}
> > > +
> > >  	edi->edi_priority = priority;
> > >  	edi->edi_retention_time = retentionTime;
> > >  
> > > @@ -1634,6 +1646,15 @@
> > >  	}
> > >  	pthread_mutex_lock(&edi->edi_mutex);
> > >  
> > > +	/*
> > > +	 * Can't get data from an event that wasn't 
> > > +	 * a delivered event.
> > > +	 */
> > > +	if (!edi->edi_ro) {
> > > +		error = SA_AIS_ERR_BAD_HANDLE;
> > > +		goto unlock_put;
> > > +	}
> > > +
> > >  	if (edi->edi_event_data && edi->edi_event_data_size) {
> > >  		xfsize = min(*eventDataSize, edi->edi_event_data_size);
> > >  		*eventDataSize = edi->edi_event_data_size;
> > > @@ -1645,6 +1666,7 @@
> > >  		*eventDataSize = 0;
> > >  	}
> > >  
> > > +unlock_put:
> > >  	pthread_mutex_unlock(&edi->edi_mutex);
> > >  	saHandleInstancePut(&event_handle_db, eventHandle);
> > >  data_get_done:
> > > Index: openais_work/test/testevt.c
> > > ===================================================================
> > > --- openais_work.orig/test/testevt.c	2005-07-07 13:22:50.000000000 -0700
> > > +++ openais_work/test/testevt.c	2005-07-07 13:28:59.000000000 -0700
> > > @@ -1121,7 +1121,7 @@
> > >  		result = saEvtEventDataGet(event_handle, event_data, 
> > >  				&event_data_size);
> > >  	} while ((result == SA_AIS_ERR_TRY_AGAIN) && !sleep(TRY_WAIT));
> > > -	if (result != SA_AIS_OK) {
> > > +	if (result != SA_AIS_ERR_BAD_HANDLE) {
> > >  		get_sa_error(result, result_buf, result_buf_len);
> > >  		printf("ERROR: Get event data(4) result: %s\n", result_buf);
> > >  	}
> > > @@ -1131,7 +1131,7 @@
> > >  		result = saEvtEventDataGet(event_handle, event_data, 
> > >  				&event_data_size);
> > >  	} while ((result == SA_AIS_ERR_TRY_AGAIN) && !sleep(TRY_WAIT));
> > > -	if (result != SA_AIS_OK) {
> > > +	if (result != SA_AIS_ERR_BAD_HANDLE) {
> > >  		get_sa_error(result, result_buf, result_buf_len);
> > >  		printf("ERROR: Get event data(5) result: %s\n", result_buf);
> > >  	}
> > > 
> > > _______________________________________________
> > > Openais mailing list
> > > Openais at lists.osdl.org
> > > https://lists.osdl.org/mailman/listinfo/openais




More information about the Openais mailing list