X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=blobdiff_plain;f=libatalk%2Futil%2Fserver_ipc.c;h=fa1778e9c99cd251c77f336fc6788121b849a888;hp=838cece7253dbf75ff832b02ab64d0c2caae573f;hb=22ad101eb72bf10fe5144526209798c677b2d1d8;hpb=01e4f40259950a534d8608e0b3e68e50fb1ca233 diff --git a/libatalk/util/server_ipc.c b/libatalk/util/server_ipc.c index 838cece7..fa1778e9 100644 --- a/libatalk/util/server_ipc.c +++ b/libatalk/util/server_ipc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -104,6 +105,45 @@ static int ipc_get_session(struct ipc_header *ipc, server_child_t *children) return 0; } +static int ipc_set_state(struct ipc_header *ipc, server_child_t *children) +{ + EC_INIT; + afp_child_t *child; + + pthread_mutex_lock(&children->servch_lock); + + if ((child = server_child_resolve(children, ipc->child_pid)) == NULL) + EC_FAIL; + + memcpy(&child->afpch_state, ipc->msg, sizeof(uint16_t)); + +EC_CLEANUP: + pthread_mutex_unlock(&children->servch_lock); + EC_EXIT; +} + +static int ipc_set_volumes(struct ipc_header *ipc, server_child_t *children) +{ + EC_INIT; + afp_child_t *child; + + pthread_mutex_lock(&children->servch_lock); + + if ((child = server_child_resolve(children, ipc->child_pid)) == NULL) + EC_FAIL; + + if (child->afpch_volumes) { + free(child->afpch_volumes); + child->afpch_volumes = NULL; + } + if (ipc->len) + child->afpch_volumes = strdup(ipc->msg); + +EC_CLEANUP: + pthread_mutex_unlock(&children->servch_lock); + EC_EXIT; +} + /*********************************************************************************** * Public functions ***********************************************************************************/ @@ -201,6 +241,16 @@ int ipc_server_read(server_child_t *children, int fd) return -1; break; + case IPC_STATE: + if (ipc_set_state(&ipc, children) != 0) + return -1; + break; + + case IPC_VOLUMES: + if (ipc_set_volumes(&ipc, children) != 0) + return -1; + break; + default: LOG (log_info, logtype_afpd, "ipc_read: unknown command: %d", ipc.command); return -1; @@ -252,3 +302,8 @@ int ipc_child_write(int fd, uint16_t command, int len, void *msg) return 0; } + +int ipc_child_state(AFPObj *obj, uint16_t state) +{ + return ipc_child_write(obj->ipc_fd, IPC_STATE, sizeof(uint16_t), &state); +}