summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-07-07 22:50:59 +0300
committerLuiz Augusto von Dentz <luiz.dentz-von@nokia.com>2010-07-07 22:50:59 +0300
commit4ff7fa79c8aaa70a627e53f99e8aace81362766a (patch)
tree379c650f36a3e6ee62a07fe0a626835917e37e77 /src
parent7f1690c1b6bd928471f6d5476f1bd29cf1f0ea84 (diff)
downloadobexd-4ff7fa79c8aaa70a627e53f99e8aace81362766a.tar.gz
core: fix not calling driver .reset when resetting session
.reset should be called in all situation that the session is reset, including when there is a socket HUP/ERR, so that the driver has a chance to cleanup properly. In addiction to that this should also fix not removing files when incomplete/aborted by checking the status when resetting the session.
Diffstat (limited to 'src')
-rw-r--r--src/obex.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/obex.c b/src/obex.c
index 4680b9d..d89f41c 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -263,8 +263,21 @@ static void os_set_response(obex_object_t *obj, int err)
OBEX_ObjectSetRsp(obj, rsp, lastrsp);
}
+static void os_session_mark_aborted(struct obex_session *os)
+{
+ /* the session was already cancelled/aborted or size in unknown */
+ if (os->aborted || os->size == OBJECT_SIZE_UNKNOWN)
+ return;
+
+ os->aborted = (os->size != os->offset);
+}
+
static void os_reset_session(struct obex_session *os)
{
+ os_session_mark_aborted(os);
+ if (os->service->reset)
+ os->service->reset(os, os->service_data);
+
if (os->object) {
os->driver->set_io_watch(os->object, NULL, NULL);
os->driver->close(os->object);
@@ -300,16 +313,6 @@ static void os_reset_session(struct obex_session *os)
os->finished = 0;
}
-static void os_session_mark_aborted(struct obex_session *os)
-{
- /* the session was alredy cancelled/aborted */
- if (os->aborted)
- return;
-
- os->aborted = os->size == OBJECT_SIZE_UNKNOWN ? FALSE :
- os->size != os->offset;
-}
-
static void obex_session_free(struct obex_session *os)
{
sessions = g_slist_remove(sessions, os);
@@ -1087,8 +1090,6 @@ static void obex_event_cb(obex_t *obex, obex_object_t *obj, int mode,
break;
case OBEX_EV_ABORT:
os->aborted = TRUE;
- if (os->service->reset)
- os->service->reset(os, os->service_data);
os_reset_session(os);
OBEX_ObjectSetRsp(obj, OBEX_RSP_SUCCESS, OBEX_RSP_SUCCESS);
break;
@@ -1103,9 +1104,6 @@ static void obex_event_cb(obex_t *obex, obex_object_t *obj, int mode,
case OBEX_CMD_GET:
case OBEX_CMD_SETPATH:
default:
- os_session_mark_aborted(os);
- if (os->service->reset)
- os->service->reset(os, os->service_data);
os_reset_session(os);
break;
}