From 8742923b56610391d5ea91db5b9d76b8f06a170b Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Mon, 17 May 2010 21:22:57 -0300 Subject: [PATCH] obexd: Fix sending the Not Found response asynchronously When we only discover that the requested resource can't be found in the async callback, we set the error using the obex_object_set_io_flags method, the Not Found case was not being handled --- obexd/plugins/pbap.c | 4 ++++ obexd/plugins/phonebook-tracker.c | 4 ++-- obexd/src/obex.c | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index 25d5e242a..2085aca0b 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -422,6 +422,10 @@ static void cache_entry_done(void *user_data) pbap->cache.valid = TRUE; id = cache_find(&pbap->cache, pbap->find_handle); + if (id == NULL) { + obex_object_set_io_flags(pbap, G_IO_ERR, -ENOENT); + return; + } ret = phonebook_get_entry(pbap->folder, id, pbap->params, query_result, pbap); diff --git a/obexd/plugins/phonebook-tracker.c b/obexd/plugins/phonebook-tracker.c index cfb350e0f..5b73fe6ef 100644 --- a/obexd/plugins/phonebook-tracker.c +++ b/obexd/plugins/phonebook-tracker.c @@ -632,7 +632,7 @@ int phonebook_pull(const char *name, const struct apparam_field *params, query = name2query(name); if (query == NULL) - return -1; + return -ENOENT; data = g_new0(struct phonebook_data, 1); data->vcards = g_string_new(NULL); @@ -675,7 +675,7 @@ int phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb, query = folder2query(name); if (query == NULL) - return -1; + return -ENOENT; cache = g_new0(struct cache_data, 1); cache->entry_cb = entry_cb; diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 15a4674a6..a39a48d36 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -464,10 +464,15 @@ proceed: case -EINVAL: OBEX_ObjectSetRsp(os->obj, OBEX_RSP_BAD_REQUEST, OBEX_RSP_BAD_REQUEST); + break; case -EPERM: OBEX_ObjectSetRsp(os->obj, OBEX_RSP_FORBIDDEN, OBEX_RSP_FORBIDDEN); break; + case -ENOENT: + OBEX_ObjectSetRsp(os->obj, OBEX_RSP_NOT_FOUND, + OBEX_RSP_NOT_FOUND); + break; default: if (ret < 0) OBEX_ObjectSetRsp(os->obj, -- 2.47.3