efl_net: check definition 'SO_REUSEPORT' for port reuse flag
authorJiwon Kim <jiwon177.kim@samsung.com>
Thu, 1 Sep 2016 17:08:11 +0000 (19:08 +0200)
committerJean Guyomarc'h <jean@guyomarch.bzh>
Thu, 1 Sep 2016 17:08:25 +0000 (19:08 +0200)
Summary:
The port reuse feature and 'SO_REUSEPORT' flag are not supported by a few linux
In case of linux kernel, it supported from v 3.9
  (https://kernelnewbies.org/Linux_3.9)
On the lower version of kernel, compile is failed

Reviewers: barbieri, jayji

Reviewed By: jayji

Subscribers: akanad, id213sin, cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4256

src/lib/ecore_con/efl_net_server_fd.c

index 33448c6..0e33e8e 100644 (file)
@@ -332,6 +332,7 @@ _efl_net_server_fd_reuse_port_set(Eo *o, Efl_Net_Server_Fd_Data *pd, Eina_Bool r
    fd = efl_loop_fd_get(o);
    if (fd < 0) return EINA_TRUE; /* postpone until fd_set() */
 
+#ifdef SO_REUSEPORT
    value = reuse_port;
    if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &value, sizeof(value)) < 0)
      {
@@ -340,8 +341,11 @@ _efl_net_server_fd_reuse_port_set(Eo *o, Efl_Net_Server_Fd_Data *pd, Eina_Bool r
         pd->reuse_port = old;
         return EINA_FALSE;
      }
-
    return EINA_TRUE;
+#else
+   pd->reuse_port = EINA_FALSE;
+   return EINA_FALSE;
+#endif
 }
 
 EOLIAN static Eina_Bool
@@ -356,6 +360,7 @@ _efl_net_server_fd_reuse_port_get(Eo *o, Efl_Net_Server_Fd_Data *pd)
    /* if there is a fd, always query it directly as it may be modified
     * elsewhere by nasty users.
     */
+#ifdef SO_REUSEPORT
    valuelen = sizeof(value);
    if (getsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &value, &valuelen) < 0)
      {
@@ -366,6 +371,9 @@ _efl_net_server_fd_reuse_port_get(Eo *o, Efl_Net_Server_Fd_Data *pd)
 
    pd->reuse_port = !!value; /* sync */
    return pd->reuse_port;
+#else
+   return EINA_FALSE;
+#endif
 }
 
 EOLIAN static void