Diff between e114d23e570b8ce8a6d82dc899c6748efe03474a and 87b420b82b2373446c5f45d73842c54e710a4909

Changed Files

File Additions Deletions Status
obexd/src/main.c +3 -2 modified
obexd/src/obex.c +22 -1 modified
obexd/src/obex.h +4 -0 modified

Full Patch

diff --git a/obexd/src/main.c b/obexd/src/main.c
index 4a3ac46..07dad2d 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -59,8 +59,8 @@
 
 static GMainLoop *main_loop = NULL;
 
-static int tty_init(int services, const gchar *root_path,
-			const gchar *capability, const gchar *devnode)
+int tty_init(int services, const gchar *root_path,
+		const gchar *capability, const gchar *devnode)
 {
 	struct server *server;
 	struct termios options;
@@ -83,6 +83,7 @@ static int tty_init(int services, const gchar *root_path,
 	server->folder = g_strdup(root_path);
 	server->auto_accept = TRUE;
 	server->capability = g_strdup(capability);
+	server->devnode = g_strdup(devnode);
 
 	ret = obex_session_start(fd, server);
 	if (ret < 0) {
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index 4768cdf..7197c94 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
@@ -881,6 +881,7 @@ void server_free(struct server *server)
 	g_free(server->name);
 	g_free(server->folder);
 	g_free(server->capability);
+	g_free(server->devnode);
 	g_free(server);
 }
 
@@ -907,6 +908,17 @@ static void obex_handle_destroy(gpointer user_data)
 	OBEX_Cleanup(obex);
 }
 
+static gboolean tty_reinit(gpointer data)
+{
+	struct server *server = data;
+
+	tty_init(server->services, server->folder, server->capability, server->devnode);
+
+	server_free(server);
+
+	return FALSE;
+}
+
 static gboolean obex_handle_input(GIOChannel *io,
 				GIOCondition cond, gpointer user_data)
 {
@@ -915,8 +927,17 @@ static gboolean obex_handle_input(GIOChannel *io,
 	if (cond & G_IO_NVAL)
 		return FALSE;
 
-	if (cond & (G_IO_HUP | G_IO_ERR))
+	if (cond & (G_IO_HUP | G_IO_ERR)) {
+		struct obex_session *os;
+
+		error("HUP");
+
+		os = OBEX_GetUserData(obex);
+		if (os->server->devnode)
+			g_idle_add(tty_reinit, os->server);
+
 		return FALSE;
+	}
 
 	if (OBEX_HandleInput(obex, 1) < 0) {
 		error("Handle input error");
diff --git a/obexd/src/obex.h b/obexd/src/obex.h
index 6718942..b9c1d67 100644
--- a/obexd/src/obex.h
+++ b/obexd/src/obex.h
@@ -52,6 +52,7 @@ struct server {
 	gchar		*capability;
 	guint32		handle;
 	uint8_t		channel;
+	gchar		*devnode;
 };
 
 struct obex_session {
@@ -92,3 +93,6 @@ gboolean os_prepare_get(struct obex_session *os, gchar *file, guint32 *size);
 gint os_prepare_put(struct obex_session *os);
 
 void server_free(struct server *server);
+
+int tty_init(gint service, const gchar *folder, const gchar *capability,
+		const gchar *devnode);