Ticket #21 (new defect)

Opened 11 months ago

Last modified 11 months ago

OBEX_EV_REQDONE 'mode' parameter problem

Reported by: elapuyade Owned by: somebody
Priority: major Milestone:
Component: openobex-lib Version:
Keywords: Cc:

Description

This is following the thread "[openobex-users] OBEX_EV_REQDONE mode problem in cvs version" in the open obex mailing list.

The fix Frederic proposed is actually not good. There is a problem when the event callback starts a new request. For example, I use the CONNECT EV_REQDONE to start a new PUT request, and that would fail with this change. The new PUT request initializes the state as it likes and then the event callback returns. But at this time, the state would be overridden with MODE_SRV.

Let me summarize the last changes:

At changestate 262, the state initialization was moved before calling obex_deliver_event. This was bad because obex_deliver_event uses it to determine the current mode. So it broke all the code who actually use the mode parameter in the event callback.

Frederic proposed to move the state initialization after obex_deliver_event. This is the patch Christian W. Zuckschwerdt said he put on his todo list. But it is also bad to set the state after obex_deliver_event for the reason I mentioned above.

I think the right way to fix this is to pre-initialize the next state before calling obex_deliver_event, and to pass the current state to obex_deliver_event as follows:

OLD IMPLEMENTATION


void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del) {

obex_object_t *object = self->object;

if (del == TRUE)

self->object = NULL;

if (self->state & MODE_SRV)

self->eventcb(self, object, OBEX_MODE_SERVER, event, cmd, rsp);

else

self->eventcb(self, object, OBEX_MODE_CLIENT, event, cmd, rsp);

if (del == TRUE)

obex_object_delete(object);

}

NEW PROPOSED IMPLEMENTATION


void obex_deliver_event(obex_t *self, int event, int cmd, int rsp, int del, int mode) {

obex_object_t *object = self->object;

if (del == TRUE)

self->object = NULL;

self->eventcb(self, object, mode, event, cmd, rsp);

if (del == TRUE)

obex_object_delete(object);

}

I am adding an svn patch file. That patch has been implemented and tested.

Attachments

deliverevent_svn.patch (14.8 KB) - added by elapuyade 11 months ago.

Change History

Changed 11 months ago by elapuyade

Changed 11 months ago by elapuyade

  • component changed from obexfs to openobex-lib

Changed 11 months ago by hsattler

As already mentioned on the mailing list, the patch should not change the function obex_deliver_event() itself but created a new function obex_deliver_event_ext() that introduces the new mode parameter. The code from the old function goes into the new function and the old function contains the if else and calls the new function. This omits the duplicated (x? a: b) that are in this patch and look plain ugly.

HS

Note: See TracTickets for help on using tickets.