/*
- * Copyright (C) 2007-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2007-2009 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
struct task task;
};
+extern int mmd_mutex;
extern struct misc_meta_data *mmd;
static int server_socket;
free(current_mop);
if (arg) {
current_mop = para_strdup(arg);
- mmd_lock();
+ mutex_lock(mmd_mutex);
strncpy(mmd->afs_mode_string, arg,
sizeof(mmd->afs_mode_string));
mmd->afs_mode_string[sizeof(mmd->afs_mode_string) - 1] = '\0';
- mmd_unlock();
+ mutex_unlock(mmd_mutex);
} else {
- mmd_lock();
+ mutex_lock(mmd_mutex);
strcpy(mmd->afs_mode_string, "dummy");
- mmd_unlock();
+ mutex_unlock(mmd_mutex);
current_mop = NULL;
}
}
st->signum = para_next_signal();
if (st->signum == SIGHUP) {
close_afs_tables();
+ parse_config_or_die(1);
t->error = open_afs_tables();
if (t->error < 0)
return;
query.data = (char *)query_shm + sizeof(*cq);
query.size = cq->query_size;
cq->handler(fd, &query);
- return 1;
+ return shm_detach(query_shm);
}
static int execute_server_command(void)
*/
__noreturn void afs_init(uint32_t cookie, int socket_fd)
{
- struct sched s;
+ static struct sched s;
int i, ret;
register_signal_task();
return -E_BAD_TABLE_NAME;
}
}
- ret = send_callback_request(create_tables_callback, &query, NULL, NULL);
+ ret = send_callback_request(create_tables_callback, &query, &send_result, &fd);
if (ret < 0)
return send_va_buffer(fd, "%s\n", para_strerror(-ret));
return ret;
return 1;
}
+/**
+ * The afs event dispatcher.
+ *
+ * \param event Type of the event.
+ * \param pb May be \p NULL.
+ * \param data Type depends on \a event.
+ *
+ * This function calls the table handlers of all tables and passes \a pb and \a
+ * data verbatim. It's up to the handlers to interpret the \a data pointer.
+ */
void afs_event(enum afs_events event, struct para_buffer *pb,
void *data)
{
continue;
ret = t->event_handler(event, pb, data);
if (ret < 0)
- PARA_CRIT_LOG("%s\n", para_strerror(-ret));
+ PARA_CRIT_LOG("table %s, event %d: %s\n", t->name,
+ event, para_strerror(-ret));
}
}