Commit 0fee202a authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Full revamp of request subsystem

parent dcbae549
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,6 +23,6 @@

ACLOCAL_AMFLAGS = -I m4

SUBDIRS = etc lib include examples src
SUBDIRS = etc lib include examples src tests

DIST_SUBDIRS = lib examples
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ AX_BOOST_SYSTEM
AX_BOOST_FILESYSTEM
AX_BOOST_ASIO
AX_BOOST_PROGRAM_OPTIONS
AX_BOOST_THREAD


# check that Intel's TBB is available. some distros don't include
@@ -107,5 +108,6 @@ AC_CONFIG_FILES([
        include/Makefile
        lib/Makefile
        src/Makefile
        tests/Makefile
])
AC_OUTPUT
+3 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ int main(int argc, char* argv[]) {
    for(int i=0; i<5; ++i) {
        if((rv = norns_add_process(&cred, 42, (uid_t) i, (gid_t) i, (pid_t) i)) != NORNS_SUCCESS) {
            fprintf(stderr, "norns_add_process failed: %s\n", norns_strerror(rv));
            exit(EXIT_FAILURE);
        }
    }

@@ -106,11 +107,13 @@ int main(int argc, char* argv[]) {

    if((rv = norns_update_job(&cred, 42, &job)) != NORNS_SUCCESS) {
        fprintf(stderr, "norns_update_job failed: %s\n", norns_strerror(rv));
        exit(EXIT_FAILURE);
    }

    // unregister the job
    if((rv = norns_unregister_job(&cred, 42)) != NORNS_SUCCESS) {
        fprintf(stderr, "norns_unregister_job failed: %s\n", norns_strerror(rv));
        exit(EXIT_FAILURE);
    }

    NORNS_PLIST_FREE(hosts1);
+64 −0
Original line number Diff line number Diff line
@@ -47,11 +47,29 @@ struct norns_membuf {
    size_t b_size;      /* memory size */
};

#define NORNS_MEMBUFFER_INIT(addr, size) \
{ \
    .b_addr = (addr), \
    .b_size = (size) \
}

struct norns_path {
    const char* p_hostname;     /* hostname (NULL if local) */
    const char* p_datapath;     /* path to "data" (i.e. file or directory) */
};

#define NORNS_LOCAL_PATH_INIT(path) \
{ \
    .p_hostname = NULL, \
    .p_datapath = (path) \
}

#define NORNS_REMOTE_PATH_INIT(hostname, path) \
{ \
    .p_hostname = (hostname), \
    .p_datapath = (path) \
}

/* Input data resource descriptor  */
struct norns_data_in {

@@ -133,6 +151,36 @@ struct norns_iotd {
//    struct norns_cred*  ni_auth;   /* process credentials (NULL if unprivileged) */
};

#define NORNS_IOTD_INIT(type, src, dst) \
{ \
    .io_taskid = 0, \
    .io_optype = (type), \
    .io_src = src, \
    .io_dst = dst \
}

#define NORNS_INPUT_PATH_INIT(type, path) \
{ \
    .in_type = (type), \
    .__in_location = { \
        .__in_path = path \
    } \
}

#define NORNS_INPUT_BUFFER_INIT(addr, size) \
{ \
    .in_type = NORNS_BACKEND_PROCESS_MEMORY, \
    .__in_location = { \
        .__in_buffer = NORNS_MEMBUFFER_INIT((addr), (size)) \
    } \
}

#define NORNS_OUTPUT_PATH_INIT(type, path) \
{ \
    .out_type = (type), \
    .out_path = path \
}




@@ -203,6 +251,14 @@ struct norns_backend {
    size_t      b_quota; /* backend capacity (in megabytes) allocated to the job for writing */
};

#define NORNS_BACKEND_INIT(type, prefix, mount, quota) \
{ \
    .b_type = (type), \
    .b_prefix = (prefix), \
    .b_mount = (mount), \
    .b_quota = (quota) \
}

#define NORNS_ALLOC(size)       \
({                              \
    size_t __n = (size);        \
@@ -237,6 +293,14 @@ struct norns_job {
    size_t                  jb_nbackends; /* entries in backend list */
};

#define NORNS_JOB_INIT(hosts, nhosts, backends, nbackends) \
{ \
    .jb_hosts = (hosts), \
    .jb_nhosts = (nhosts), \
    .jb_backends = (backends), \
    .jb_nbackends = (nbackends) \
}


/* Send a command to the daemon (e.g. stop accepting new tasks) */
int norns_command(struct norns_cred* auth);
+13 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#EXTRA_DIST = messages.proto

MOSTLYCLEANFILES = \
	defaults.c \
	messages.pb-c.c \
	messages.pb-c.h

@@ -52,7 +53,10 @@ libnorns_la_SOURCES = \
	xstring.c \
	xstring.h \
	$(top_srcdir)/include/norns.h \
	$(top_srcdir)/rpc/norns-rpc.h \
	$(top_srcdir)/rpc/norns-rpc.h

nodist_libnorns_la_SOURCES = \
	defaults.c \
	messages.pb-c.c \
	messages.pb-c.h

@@ -66,8 +70,16 @@ libnorns_la_LIBADD = \
	@PROTOBUF_C_LIBS@

BUILT_SOURCES = \
	defaults.c \
	messages.pb-c.c \
	messages.pb-c.h

defaults.c: Makefile
	@( echo "/* This file was autogenerated by Makefile */"; \
	   echo "#include \"defaults.h\""; \
	   echo ""; \
	   echo "const char* norns_api_sockfile = \"/tmp/urd.socket\";"; \
	) > $@

%.pb-c.c %.pb-c.h: $(top_srcdir)/rpc/%.proto
	$(PROTOC_C) --proto_path=$(top_srcdir)/rpc --c_out=$(builddir) $^
Loading