diff options
author | Aki Niemi <aki.niemi@nokia.com> | 2009-06-22 18:15:47 +0300 |
---|---|---|
committer | Aki Niemi <aki.niemi@nokia.com> | 2009-06-22 21:17:14 +0300 |
commit | f2f0fd0501dd16a3af710367474ad37f1d689861 (patch) | |
tree | 95e9a76e6feca08ce8a6a567637c42e39369d6f1 /gisi | |
parent | 841060da245539f7cce644c70077fb56811a6f31 (diff) | |
download | ofono-f2f0fd0501dd16a3af710367474ad37f1d689861.tar.gz |
gisi: fixes to request/response handling and timeout registration
Diffstat (limited to 'gisi')
-rw-r--r-- | gisi/client.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/gisi/client.c b/gisi/client.c index e77572b6..5fc81493 100644 --- a/gisi/client.c +++ b/gisi/client.c @@ -191,7 +191,7 @@ GIsiRequest *g_isi_request_make(GIsiClient *cl, const void *__restrict buf, ret = sendmsg(cl->fd, &msg, MSG_NOSIGNAL); if (ret == -1) return NULL; - if (ret != (ssize_t)(len + 2)) { + if (ret != (ssize_t)(len + 1)) { errno = EMSGSIZE; return NULL; } @@ -210,7 +210,8 @@ GIsiRequest *g_isi_request_make(GIsiClient *cl, const void *__restrict buf, if (timeout > 0) cl->timeout[id] = g_timeout_add_seconds(timeout, - g_isi_timeout, cl); + g_isi_timeout, + g_isi_req(cl, id)); else cl->timeout[id] = 0; return g_isi_req(cl, id); @@ -344,22 +345,29 @@ static gboolean g_isi_callback(GIOChannel *channel, GIOCondition cond, len = phonet_peek_length(channel); { uint32_t buf[(len + 3) / 4]; + uint8_t *msg; uint16_t obj; uint8_t res, id; len = phonet_read(channel, buf, len, &obj, &res); if (len < 2 || res != cl->resource) return TRUE; - memcpy(&id, buf, 1); /* Transaction ID or indication type */ + + msg = (uint8_t *)buf; if (indication) { + /* Message ID at offset 1 */ + id = msg[1]; if (cl->ind.func[id] == NULL) return TRUE; /* Unsubscribed indication */ - cl->ind.func[id](cl, buf + 1, len - 1, obj, + cl->ind.func[id](cl, msg + 1, len - 1, obj, cl->ind.data[id]); } else { - if (cl->func[id] == NULL) + /* Transaction ID at offset 0 */ + id = msg[0]; + if (cl->func[id] == NULL) { return TRUE; /* Bad transaction ID */ - if ((cl->func[id])(cl, buf + 1, len - 1, obj, + } + if ((cl->func[id])(cl, msg + 1, len - 1, obj, cl->data[id])) g_isi_request_cancel(g_isi_req(cl, id)); } |