* [PATCH obexd 2/8] gobex: Translate posix error code to proper OBEX response opcode
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
@ 2012-02-18 15:18 ` Luiz Augusto von Dentz
2012-02-18 15:18 ` [PATCH obexd 3/8] core: Make use of g_obex_errno_to_rsp to translate posix errors Luiz Augusto von Dentz
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-18 15:18 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This patch create a map between posix errors code and OBEX response
opcode and use it to generate a proper response in case a transfer
failed instead of always responding with internal error.
---
gobex/gobex-transfer.c | 6 ++++--
gobex/gobex.c | 24 ++++++++++++++++++++++++
gobex/gobex.h | 1 +
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/gobex/gobex-transfer.c b/gobex/gobex-transfer.c
index a779e4f..c62a91e 100644
--- a/gobex/gobex-transfer.c
+++ b/gobex/gobex-transfer.c
@@ -501,6 +501,7 @@ static gssize get_get_data(void *buf, gsize len, gpointer user_data)
GObexPacket *req, *rsp;
GError *err = NULL;
gssize ret;
+ guint8 op;
g_obex_debug(G_OBEX_DEBUG_TRANSFER, "transfer %u", transfer->id);
@@ -530,8 +531,9 @@ static gssize get_get_data(void *buf, gsize len, gpointer user_data)
return ret;
}
- req = g_obex_packet_new(G_OBEX_RSP_INTERNAL_SERVER_ERROR, TRUE,
- G_OBEX_HDR_INVALID);
+ op = g_obex_errno_to_rsp(ret);
+
+ req = g_obex_packet_new(op, TRUE, G_OBEX_HDR_INVALID);
g_obex_send(transfer->obex, req, NULL);
err = g_error_new(G_OBEX_ERROR, G_OBEX_ERROR_CANCELLED,
diff --git a/gobex/gobex.c b/gobex/gobex.c
index c1e7dc4..0ced782 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -1471,3 +1471,27 @@ guint g_obex_move(GObex *obex, const char *name, const char *dest,
return g_obex_send_req(obex, req, -1, func, user_data, err);
}
+
+guint8 g_obex_errno_to_rsp(int err)
+{
+ switch (err) {
+ case 0:
+ return G_OBEX_RSP_SUCCESS;
+ case -EPERM:
+ case -EACCES:
+ return G_OBEX_RSP_FORBIDDEN;
+ case -ENOENT:
+ return G_OBEX_RSP_NOT_FOUND;
+ case -EBADR:
+ return G_OBEX_RSP_BAD_REQUEST;
+ case -EFAULT:
+ return G_OBEX_RSP_SERVICE_UNAVAILABLE;
+ case -EINVAL:
+ return G_OBEX_RSP_NOT_IMPLEMENTED;
+ case -ENOTEMPTY:
+ case -EEXIST:
+ return G_OBEX_RSP_PRECONDITION_FAILED;
+ default:
+ return G_OBEX_RSP_INTERNAL_SERVER_ERROR;
+ }
+}
diff --git a/gobex/gobex.h b/gobex/gobex.h
index 1c47c68..aacdb53 100644
--- a/gobex/gobex.h
+++ b/gobex/gobex.h
@@ -125,5 +125,6 @@ guint g_obex_get_rsp_pkt(GObex *obex, GObexPacket *rsp,
gboolean g_obex_cancel_transfer(guint id);
const char *g_obex_strerror(guint8 err_code);
+guint8 g_obex_errno_to_rsp(int err);
#endif /* __GOBEX_H */
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH obexd 3/8] core: Make use of g_obex_errno_to_rsp to translate posix errors
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
2012-02-18 15:18 ` [PATCH obexd 2/8] gobex: Translate posix error code to proper OBEX response opcode Luiz Augusto von Dentz
@ 2012-02-18 15:18 ` Luiz Augusto von Dentz
2012-02-18 15:18 ` [PATCH obexd 4/8] gobex: Use ENOSYS to correspond to OBEX not implemented Luiz Augusto von Dentz
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-18 15:18 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
src/obex.c | 28 +---------------------------
1 files changed, 1 insertions(+), 27 deletions(-)
diff --git a/src/obex.c b/src/obex.c
index a028156..2b10103 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -174,33 +174,7 @@ static void os_set_response(struct obex_session *os, int err)
{
uint8_t rsp;
- switch (err) {
- case 0:
- rsp = G_OBEX_RSP_SUCCESS;
- break;
- case -EPERM:
- case -EACCES:
- rsp = G_OBEX_RSP_FORBIDDEN;
- break;
- case -ENOENT:
- rsp = G_OBEX_RSP_NOT_FOUND;
- break;
- case -EBADR:
- rsp = G_OBEX_RSP_BAD_REQUEST;
- break;
- case -EFAULT:
- rsp = G_OBEX_RSP_SERVICE_UNAVAILABLE;
- break;
- case -EINVAL:
- rsp = G_OBEX_RSP_NOT_IMPLEMENTED;
- break;
- case -ENOTEMPTY:
- case -EEXIST:
- rsp = G_OBEX_RSP_PRECONDITION_FAILED;
- break;
- default:
- rsp = G_OBEX_RSP_INTERNAL_SERVER_ERROR;
- }
+ rsp = g_obex_errno_to_rsp(err);
print_event(-1, rsp);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH obexd 4/8] gobex: Use ENOSYS to correspond to OBEX not implemented
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
2012-02-18 15:18 ` [PATCH obexd 2/8] gobex: Translate posix error code to proper OBEX response opcode Luiz Augusto von Dentz
2012-02-18 15:18 ` [PATCH obexd 3/8] core: Make use of g_obex_errno_to_rsp to translate posix errors Luiz Augusto von Dentz
@ 2012-02-18 15:18 ` Luiz Augusto von Dentz
2012-02-18 15:19 ` [PATCH obexd 5/8] core: Use ENOSYS to indicate not implemented function Luiz Augusto von Dentz
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-18 15:18 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
ENOSYS correspond to function not implemented which is exactly what the
OBEX error code means.
Also since EINVAL means invalid argument that now map to OBEX bad request
---
gobex/gobex.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gobex/gobex.c b/gobex/gobex.c
index 0ced782..0665749 100644
--- a/gobex/gobex.c
+++ b/gobex/gobex.c
@@ -1482,11 +1482,12 @@ guint8 g_obex_errno_to_rsp(int err)
return G_OBEX_RSP_FORBIDDEN;
case -ENOENT:
return G_OBEX_RSP_NOT_FOUND;
+ case -EINVAL:
case -EBADR:
return G_OBEX_RSP_BAD_REQUEST;
case -EFAULT:
return G_OBEX_RSP_SERVICE_UNAVAILABLE;
- case -EINVAL:
+ case -ENOSYS:
return G_OBEX_RSP_NOT_IMPLEMENTED;
case -ENOTEMPTY:
case -EEXIST:
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH obexd 5/8] core: Use ENOSYS to indicate not implemented function
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
` (2 preceding siblings ...)
2012-02-18 15:18 ` [PATCH obexd 4/8] gobex: Use ENOSYS to correspond to OBEX not implemented Luiz Augusto von Dentz
@ 2012-02-18 15:19 ` Luiz Augusto von Dentz
2012-02-18 15:19 ` [PATCH obexd 6/8] ftp: " Luiz Augusto von Dentz
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-18 15:19 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
src/obex.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/obex.c b/src/obex.c
index 2b10103..786398d 100644
--- a/src/obex.c
+++ b/src/obex.c
@@ -767,7 +767,7 @@ static void cmd_get(GObex *obex, GObexPacket *req, gpointer user_data)
}
if (os->service->get == NULL) {
- os_set_response(os, -EINVAL);
+ os_set_response(os, -ENOSYS);
return;
}
@@ -782,7 +782,7 @@ static void cmd_get(GObex *obex, GObexPacket *req, gpointer user_data)
if (!os->driver) {
error("No driver found");
- os_set_response(os, -EINVAL);
+ os_set_response(os, -ENOSYS);
return;
}
@@ -814,7 +814,7 @@ static void cmd_setpath(GObex *obex, GObexPacket *req, gpointer user_data)
}
if (os->service->setpath == NULL) {
- err = -EINVAL;
+ err = -ENOSYS;
goto done;
}
@@ -955,7 +955,7 @@ static void cmd_put(GObex *obex, GObexPacket *req, gpointer user_data)
if (os->driver == NULL) {
error("No driver found");
- os_set_response(os, -EINVAL);
+ os_set_response(os, -ENOSYS);
return;
}
@@ -971,7 +971,7 @@ static void cmd_put(GObex *obex, GObexPacket *req, gpointer user_data)
}
if (os->service->put == NULL) {
- os_set_response(os, -EINVAL);
+ os_set_response(os, -ENOSYS);
return;
}
@@ -1036,7 +1036,7 @@ static void cmd_action(GObex *obex, GObexPacket *req, gpointer user_data)
}
if (os->service->action == NULL) {
- err = -EINVAL;
+ err = -ENOSYS;
goto done;
}
@@ -1052,7 +1052,7 @@ static void cmd_action(GObex *obex, GObexPacket *req, gpointer user_data)
os->service->who,
os->service->who_size);
if (os->driver == NULL) {
- err = -EINVAL;
+ err = -ENOSYS;
goto done;
}
@@ -1168,7 +1168,7 @@ const char *obex_get_type(struct obex_session *os)
int obex_remove(struct obex_session *os, const char *path)
{
if (os->driver == NULL)
- return -EINVAL;
+ return -ENOSYS;
return os->driver->remove(path);
}
@@ -1177,7 +1177,7 @@ int obex_copy(struct obex_session *os, const char *source,
const char *destination)
{
if (os->driver == NULL || os->driver->copy == NULL)
- return -EINVAL;
+ return -ENOSYS;
DBG("%s %s", source, destination);
@@ -1188,7 +1188,7 @@ int obex_move(struct obex_session *os, const char *source,
const char *destination)
{
if (os->driver == NULL || os->driver->move == NULL)
- return -EINVAL;
+ return -ENOSYS;
DBG("%s %s", source, destination);
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH obexd 6/8] ftp: Use ENOSYS to indicate not implemented function
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
` (3 preceding siblings ...)
2012-02-18 15:19 ` [PATCH obexd 5/8] core: Use ENOSYS to indicate not implemented function Luiz Augusto von Dentz
@ 2012-02-18 15:19 ` Luiz Augusto von Dentz
2012-02-18 15:19 ` [PATCH obexd 7/8] core: " Luiz Augusto von Dentz
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-18 15:19 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
plugins/ftp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/plugins/ftp.c b/plugins/ftp.c
index 56cedb9..ff4b761 100644
--- a/plugins/ftp.c
+++ b/plugins/ftp.c
@@ -500,7 +500,7 @@ int ftp_action(struct obex_session *os, void *user_data)
case 0x01: /* Move/Rename Object */
return ftp_move(ftp, name, destname);
default:
- return -EINVAL;
+ return -ENOSYS;
}
}
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH obexd 7/8] core: Use ENOSYS to indicate not implemented function
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
` (4 preceding siblings ...)
2012-02-18 15:19 ` [PATCH obexd 6/8] ftp: " Luiz Augusto von Dentz
@ 2012-02-18 15:19 ` Luiz Augusto von Dentz
2012-02-18 15:19 ` [PATCH obexd 8/8] map: " Luiz Augusto von Dentz
2012-02-19 22:19 ` [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Johan Hedberg
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-18 15:19 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
plugins/opp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/plugins/opp.c b/plugins/opp.c
index d9b68b2..fa3ee91 100644
--- a/plugins/opp.c
+++ b/plugins/opp.c
@@ -120,7 +120,7 @@ static int opp_chkput(struct obex_session *os, void *user_data)
int err;
if (obex_get_size(os) == OBJECT_SIZE_DELETE)
- return -EINVAL;
+ return -ENOSYS;
t = obex_get_name(os);
if (t != NULL && !is_filename(t))
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH obexd 8/8] map: Use ENOSYS to indicate not implemented function
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
` (5 preceding siblings ...)
2012-02-18 15:19 ` [PATCH obexd 7/8] core: " Luiz Augusto von Dentz
@ 2012-02-18 15:19 ` Luiz Augusto von Dentz
2012-02-19 22:19 ` [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Johan Hedberg
7 siblings, 0 replies; 9+ messages in thread
From: Luiz Augusto von Dentz @ 2012-02-18 15:19 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
plugins/mas.c | 4 ++--
plugins/messages-dummy.c | 10 +++++-----
plugins/messages-tracker.c | 8 ++++----
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/plugins/mas.c b/plugins/mas.c
index 17e54d8..23b1823 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -501,7 +501,7 @@ static void *message_open(const char *name, int oflag, mode_t mode,
if (oflag != O_RDONLY) {
DBG("Message pushing unsupported");
- *err = -EINVAL;
+ *err = -ENOSYS;
return NULL;
}
@@ -542,7 +542,7 @@ static void *any_open(const char *name, int oflag, mode_t mode,
{
DBG("");
- *err = -EINVAL;
+ *err = -ENOSYS;
return NULL;
}
diff --git a/plugins/messages-dummy.c b/plugins/messages-dummy.c
index dd97ee1..511857e 100644
--- a/plugins/messages-dummy.c
+++ b/plugins/messages-dummy.c
@@ -93,7 +93,7 @@ int messages_set_notification_registration(void *session,
const struct messages_event *event, void *user_data),
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
int messages_set_folder(void *s, const char *name, gboolean cdup)
@@ -147,7 +147,7 @@ int messages_get_folder_listing(void *session, const char *name, uint16_t max,
messages_folder_listing_cb callback,
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
int messages_get_messages_listing(void *session, const char *name,
@@ -156,7 +156,7 @@ int messages_get_messages_listing(void *session, const char *name,
messages_get_messages_listing_cb callback,
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
int messages_get_message(void *session, const char *handle,
@@ -164,13 +164,13 @@ int messages_get_message(void *session, const char *handle,
messages_get_message_cb callback,
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
int messages_update_inbox(void *session, messages_update_inbox_cb callback,
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
void messages_abort(void *session)
diff --git a/plugins/messages-tracker.c b/plugins/messages-tracker.c
index 8d9d8bd..fb45210 100644
--- a/plugins/messages-tracker.c
+++ b/plugins/messages-tracker.c
@@ -185,7 +185,7 @@ int messages_set_notification_registration(void *session,
const struct messages_event *event, void *user_data),
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
int messages_set_folder(void *s, const char *name, gboolean cdup)
@@ -310,7 +310,7 @@ int messages_get_messages_listing(void *session,
messages_get_messages_listing_cb callback,
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
int messages_get_message(void *session, const char *handle,
@@ -318,13 +318,13 @@ int messages_get_message(void *session, const char *handle,
messages_get_message_cb callback,
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
int messages_update_inbox(void *session, messages_update_inbox_cb callback,
void *user_data)
{
- return -EINVAL;
+ return -ENOSYS;
}
void messages_abort(void *session)
--
1.7.7.6
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended
2012-02-18 15:18 [PATCH obexd 1/8] core: Fix queueing packet containing error while suspended Luiz Augusto von Dentz
` (6 preceding siblings ...)
2012-02-18 15:19 ` [PATCH obexd 8/8] map: " Luiz Augusto von Dentz
@ 2012-02-19 22:19 ` Johan Hedberg
7 siblings, 0 replies; 9+ messages in thread
From: Johan Hedberg @ 2012-02-19 22:19 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
Hi Luiz,
On Sat, Feb 18, 2012, Luiz Augusto von Dentz wrote:
> Queueing the error won't remove the original packet created by transfer
> from the queue so upon resume gobex will attempt to send it again.
>
> To fix this we no longer create a error packet instead the session is
> market as aborted and the error stored so when gobex finally resumes the
> error is forward properly.
> ---
> src/obex-priv.h | 1 +
> src/obex.c | 10 ++++++----
> 2 files changed, 7 insertions(+), 4 deletions(-)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 9+ messages in thread