summaryrefslogtreecommitdiff
path: root/nslcd/hackers.c
blob: fe0e614c2ca5237d25067f088aee0b202b336c94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <pthread.h>
#include "hackers_watch.h"
#include "log.h"

static
void *
session_worker(void *sess) {
	hackers_session_worker(sess);
	return NULL;
}

struct session *
session_create(const struct nslcd_config *cfg, pthread_t *thread) {
	struct session *session = hackers_session_allocate();
	if (session == NULL) {
		exit(EXIT_FAILURE);
	}

	if (hackers_session_open(session, cfg->yamldir) != 0) {
		exit(EXIT_FAILURE);
	}

	if (pthread_create(thread, NULL, session_worker, (void*)session)) {
		log_log(LOG_ERR, "unable to start hackers worker thread: %s",
		        strerror(errno));
		exit(EXIT_FAILURE);
	}

	return session;
}

void
session_check(struct session *sess) {
	/* do nothing */
}

void
session_close(struct session *sess) {
	/*hackers_session_close(sess);*/
}

void
session_refresh(struct session *sess, const struct nslcd_config *cfg) {
	if (hackers_session_open(sess, cfg->yamldir) != 0) {
		exit(EXIT_FAILURE);
	}
}

void
session_messup(struct session *sess) {
	pthread_rwlock_rdlock(&(sess->lock));
}

void
session_cleanup(struct session *sess) {
	pthread_rwlock_unlock(&(sess->lock));
}