[PATCH v2 6/9] obexd: Queue mkdir command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christian Fetzer <christian.fetzer@xxxxxxxxxxxx>

diff --git a/obexd/client/session.c b/obexd/client/session.c
index 6036d33..6b33f3e 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -1055,10 +1055,29 @@ static void file_op_complete(struct obc_session *session,
 		data->func(session, NULL, err, data->user_data);
 }
 
+static int session_process_mkdir(struct pending_request *p, GError **err)
+{
+	struct file_data *req = p->data;
+
+	p->req_id = g_obex_mkdir(p->session->obex, req->srcname, async_cb, p,
+									err);
+	if (*err != NULL)
+		goto fail;
+
+	p->session->p = p;
+
+	return 0;
+
+fail:
+	pending_request_free(p);
+	return (*err)->code;
+}
+
 guint obc_session_mkdir(struct obc_session *session, const char *folder,
 				session_callback_t func, void *user_data,
 				GError **err)
 {
+	struct file_data *data;
 	struct pending_request *p;
 
 	if (session->obex == NULL) {
@@ -1067,21 +1086,14 @@ guint obc_session_mkdir(struct obc_session *session, const char *folder,
 		return 0;
 	}
 
-	if (session->p != NULL) {
-		g_set_error(err, OBEX_IO_ERROR, OBEX_IO_BUSY, "Session busy");
-		return 0;
-	}
-
-
-	p = pending_request_new(session, NULL, NULL, NULL, func, user_data);
-
-	p->req_id = g_obex_mkdir(session->obex, folder, async_cb, p, err);
-	if (*err != NULL) {
-		pending_request_free(p);
-		return 0;
-	}
+	data = g_new0(struct file_data, 1);
+	data->srcname = g_strdup(folder);
+	data->func = func;
+	data->user_data = user_data;
 
-	session->p = p;
+	p = pending_request_new(session, session_process_mkdir,
+					file_data_free, NULL, func, data);
+	session_queue_add(p);
 	return p->id;
 }
 
-- 
1.8.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux