summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con/efl_net_server_unix.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-23 18:38:24 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-23 18:38:24 -0200
commitd0b6aa6596884fc4db5287bd8e3c2cee9db1f031 (patch)
treec2976becc28a8538fcaa0bfcf565e69401fbb76e /src/lib/ecore_con/efl_net_server_unix.c
parentfc76abccd6fa694d5fbdc4fc85b65c9004e12271 (diff)
efl_net_server_unix: do bind() from serve() method.
Instead of adding a job to create the socket and call bind(), do it straight from the serve() method, this allows the caller to set umask(), permissions and so on. Document this behavior in the class, since we can't extend the method's documentation.
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_con/efl_net_server_unix.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/lib/ecore_con/efl_net_server_unix.c b/src/lib/ecore_con/efl_net_server_unix.c
index 7e90bb8cd8..288c530c75 100644
--- a/src/lib/ecore_con/efl_net_server_unix.c
+++ b/src/lib/ecore_con/efl_net_server_unix.c
@@ -24,7 +24,6 @@
24 24
25typedef struct _Efl_Net_Server_Unix_Data 25typedef struct _Efl_Net_Server_Unix_Data
26{ 26{
27 Efl_Future *bind_job;
28 Eina_Bool unlink_before_bind; 27 Eina_Bool unlink_before_bind;
29} Efl_Net_Server_Unix_Data; 28} Efl_Net_Server_Unix_Data;
30 29
@@ -43,11 +42,9 @@ _efl_net_server_unix_efl_object_destructor(Eo *o, Efl_Net_Server_Unix_Data *pd E
43 efl_destructor(efl_super(o, MY_CLASS)); 42 efl_destructor(efl_super(o, MY_CLASS));
44} 43}
45 44
46static void 45static Eina_Error
47_efl_net_server_unix_bind_job(void *data, const Efl_Event *event EINA_UNUSED) 46_efl_net_server_unix_bind(Eo *o, Efl_Net_Server_Unix_Data *pd)
48{ 47{
49 Eo *o = data;
50 Efl_Net_Server_Unix_Data *pd = efl_data_scope_get(o, MY_CLASS);
51 const char *address = efl_net_server_address_get(o); 48 const char *address = efl_net_server_address_get(o);
52 struct sockaddr_un addr = { .sun_family = AF_UNIX }; 49 struct sockaddr_un addr = { .sun_family = AF_UNIX };
53 socklen_t addrlen; 50 socklen_t addrlen;
@@ -55,10 +52,6 @@ _efl_net_server_unix_bind_job(void *data, const Efl_Event *event EINA_UNUSED)
55 Eina_Error err = 0; 52 Eina_Error err = 0;
56 int r; 53 int r;
57 54
58 pd->bind_job = NULL;
59
60 efl_ref(o); /* we're emitting callbacks then continuing the workflow */
61
62 efl_net_server_fd_family_set(o, AF_UNIX); 55 efl_net_server_fd_family_set(o, AF_UNIX);
63 56
64 do 57 do
@@ -158,8 +151,7 @@ _efl_net_server_unix_bind_job(void *data, const Efl_Event *event EINA_UNUSED)
158 if (fd != INVALID_SOCKET) closesocket(fd); 151 if (fd != INVALID_SOCKET) closesocket(fd);
159 efl_loop_fd_set(o, SOCKET_TO_LOOP_FD(INVALID_SOCKET)); 152 efl_loop_fd_set(o, SOCKET_TO_LOOP_FD(INVALID_SOCKET));
160 } 153 }
161 154 return err;
162 efl_unref(o);
163} 155}
164 156
165EOLIAN static Eina_Error 157EOLIAN static Eina_Error
@@ -228,14 +220,7 @@ _efl_net_server_unix_efl_net_server_serve(Eo *o, Efl_Net_Server_Unix_Data *pd, c
228 220
229 efl_net_server_address_set(o, address); 221 efl_net_server_address_set(o, address);
230 222
231 if (pd->bind_job) 223 return _efl_net_server_unix_bind(o, pd);
232 efl_future_cancel(pd->bind_job);
233
234 efl_future_use(&pd->bind_job, efl_loop_job(efl_loop_get(o), o));
235 efl_future_then(pd->bind_job, _efl_net_server_unix_bind_job, NULL, NULL, o);
236 efl_future_link(o, pd->bind_job);
237
238 return 0;
239} 224}
240 225
241static Efl_Callback_Array_Item *_efl_net_server_unix_client_cbs(void); 226static Efl_Callback_Array_Item *_efl_net_server_unix_client_cbs(void);