Triton-commits
Threads by month
- ----- 2026 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
July 2011
- 1 participants
- 12 discussions
Triton Repository branch, master, updated. e06a92b3380444c8c64551e984229cd80dd96699
by noreply@mcs.anl.gov 29 Jul '11
by noreply@mcs.anl.gov 29 Jul '11
29 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via e06a92b3380444c8c64551e984229cd80dd96699 (commit)
from ff186b9f6acf42f0dfc2dddbc0bcd707ecc9d311 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e06a92b3380444c8c64551e984229cd80dd96699
Author: Philip Carns <carns(a)mcs.anl.gov>
Date: Fri Jul 29 08:58:22 2011 -0500
only check for readability on accept socket
-----------------------------------------------------------------------
Summary of changes:
code/src/socket/triton-socket.ae | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
Diff of changes:
diff --git a/code/src/socket/triton-socket.ae b/code/src/socket/triton-socket.ae
index 75ce7a9..9de2903 100644
--- a/code/src/socket/triton-socket.ae
+++ b/code/src/socket/triton-socket.ae
@@ -31,7 +31,7 @@ __blocking triton_ret_t triton_accept(
}
else if (errno == EAGAIN || errno == EWOULDBLOCK)
{
- ret = triton_aesocket_ready(sockfd, AESOCKET_READ | AESOCKET_WRITE);
+ ret = triton_aesocket_ready(sockfd, AESOCKET_READ);
if (ret != TRITON_SUCCESS)
return ret;
}
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. ff186b9f6acf42f0dfc2dddbc0bcd707ecc9d311
by noreply@mcs.anl.gov 28 Jul '11
by noreply@mcs.anl.gov 28 Jul '11
28 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via ff186b9f6acf42f0dfc2dddbc0bcd707ecc9d311 (commit)
from b540d82e6742c81af5a516448aff121caac45d94 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ff186b9f6acf42f0dfc2dddbc0bcd707ecc9d311
Author: Phil Carns <pcarns(a)carns-x220.(none)>
Date: Thu Jul 28 14:01:49 2011 -0400
clean out unused code
-----------------------------------------------------------------------
Summary of changes:
code/src/common/resources/aesocket/aesocket.c | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
Diff of changes:
diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c
index ba3ec76..a2eb690 100644
--- a/code/src/common/resources/aesocket/aesocket.c
+++ b/code/src/common/resources/aesocket/aesocket.c
@@ -20,11 +20,6 @@ struct ae_context
ev_async eloop_breaker;
};
-
-/* TODO: this is a hack for testing */
-#define MAX_FDS 1024
-char known_fds[MAX_FDS] = {0};
-
#define AESOCKET_DEFAULT_SIZE 1024
static ae_opcache_t aesocket_opcache = NULL;
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. b540d82e6742c81af5a516448aff121caac45d94
by noreply@mcs.anl.gov 28 Jul '11
by noreply@mcs.anl.gov 28 Jul '11
28 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via b540d82e6742c81af5a516448aff121caac45d94 (commit)
from d971682ce443fb65a5c569f0909d4010a83e9683 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b540d82e6742c81af5a516448aff121caac45d94
Author: Phil Carns <pcarns(a)carns-x220.(none)>
Date: Thu Jul 28 12:04:56 2011 -0400
remove raw epoll support, use libev only
re #133
-----------------------------------------------------------------------
Summary of changes:
code/Makefile.in | 4 -
code/src/aesop/resource.c | 395 +------------------------
code/src/aesop/resource.h | 2 -
code/src/common/resources/aesocket/aesocket.c | 175 -----------
code/src/common/resources/timer/timer.c | 109 +-------
5 files changed, 5 insertions(+), 680 deletions(-)
Diff of changes:
diff --git a/code/Makefile.in b/code/Makefile.in
index 10fc5a0..6e01c2f 100644
--- a/code/Makefile.in
+++ b/code/Makefile.in
@@ -95,10 +95,6 @@ LIBCFLAGS=@LIBCFLAGS@
# in the module.mk.in because we need it to take effect when the .d file is
# generated as well.
LIBCFLAGS += -DEV_CONFIG_H=\"triton-config.h\"
-# switch which of the following two lines is commented if you want to
-# disable libev and go back to using epoll for the aesop polling strategy
-#LIBCFLAGS += -D__AESOP_EPOLL
-LIBCFLAGS += -D__AESOP_LIBEV
LDFLAGS += @LDFLAGS@
LIBS += @LIBS@ -lcrypto
diff --git a/code/src/aesop/resource.c b/code/src/aesop/resource.c
index bc4619f..b2a5309 100644
--- a/code/src/aesop/resource.c
+++ b/code/src/aesop/resource.c
@@ -1,16 +1,4 @@
-#if !defined (__AESOP_EPOLL) && !defined (__AESOP_LIBEV)
-#error Must define one of __AESOP_EPOLL or __AESOP_LIBEV
-#endif
-#if defined (__AESOP_EPOLL) && defined (__AESOP_LIBEV)
-#error Must define exactly one of __AESOP_EPOLL or __AESOP_LIBEV, not both
-#endif
-
-#ifdef __AESOP_EPOLL
-#include <sys/epoll.h>
-#endif
-#ifdef __AESOP_LIBEV
#include "src/common/libev/ev.h"
-#endif
#include <stddef.h>
#include <unistd.h>
#include <fcntl.h>
@@ -21,12 +9,7 @@
struct ae_poll_data
{
-#ifdef __AESOP_EPOLL
- int pipe_fds[2];
-#endif
-#ifdef __AESOP_LIBEV
ev_async async;
-#endif
triton_ret_t (*poll_context)(ae_context_t context);
ae_context_t context;
};
@@ -42,14 +25,8 @@ triton_debug_mask_t aesop_debug_cancel_mask;
static int ae_resource_count = 0;
static struct ae_resource_entry ae_resource_entries[AE_MAX_RESOURCES];
-#ifdef __AESOP_EPOLL
-static int efd = -1;
-struct ae_poll_data break_target;
-#endif
-#ifdef __AESOP_LIBEV
static struct ev_loop *eloop = NULL;
ev_async eloop_breaker;
-#endif
static pthread_t ev_loop_thread;
#define AE_RESOURCE_IDX2ID(reindex) (reindex+16)
@@ -61,99 +38,13 @@ struct ae_context
int resource_count;
int* resource_ids;
struct ae_poll_data* poll_data;
-#ifdef __AESOP_EPOLL
- struct ae_poll_data break_target;
- int efd;
-#endif
-#ifdef __AESOP_LIBEV
struct ev_loop *eloop;
ev_async eloop_breaker;
-#endif
};
static int ae_context_count = 0;
static struct ae_context ae_context_entries[AE_MAX_CONTEXTS];
-#ifdef __AESOP_EPOLL
-triton_ret_t ae_resource_register(struct ae_resource *resource, int *newid)
-{
- int reindex = ae_resource_count;
- int ret;
- struct epoll_event event;
-
- if(efd < 0)
- {
- /* This is the first resource to be registered. Initialize the
- * epoll fd and create a pipe that can be used to break the epoll
- * wait.
- */
- efd = epoll_create(32);
- if(efd < 0)
- {
- triton_err(triton_log_default, "Error: could not create epoll fd for resource polling.\n");
- return(TRITON_ERR_EPOLL);
- }
- ret = pipe(break_target.pipe_fds);
- if(ret < 0)
- {
- triton_err(triton_log_default, "Error: could not create pipe for resource polling.\n");
- close(efd);
- return(TRITON_ERR_EPOLL);
- }
- fcntl(break_target.pipe_fds[0], F_SETFL, O_NONBLOCK);
- fcntl(break_target.pipe_fds[1], F_SETFL, O_NONBLOCK);
- break_target.context = NULL;
- break_target.poll_context = NULL;
- event.data.ptr = &break_target;
- event.events = EPOLLIN;
- ret = epoll_ctl(efd, EPOLL_CTL_ADD, break_target.pipe_fds[0], &event);
- if(ret < 0)
- {
- triton_err(triton_log_default, "Error: could not epoll fd for resource polling.\n");
- close(efd);
- close(break_target.pipe_fds[0]);
- close(break_target.pipe_fds[1]);
- return(TRITON_ERR_EPOLL);
- }
- }
-
- if(ae_resource_count == AE_MAX_RESOURCES)
- {
- return TRITON_ERR_INVAL;
- }
-
- ret = pipe(ae_resource_entries[reindex].poll_data.pipe_fds);
- if(ret < 0)
- {
- triton_err(triton_log_default, "Error: could not create pipe for resource polling.\n");
- return(TRITON_ERR_EPOLL);
-
- }
- fcntl(ae_resource_entries[reindex].poll_data.pipe_fds[0], F_SETFL, O_NONBLOCK);
- fcntl(ae_resource_entries[reindex].poll_data.pipe_fds[1], F_SETFL, O_NONBLOCK);
- ae_resource_entries[reindex].poll_data.poll_context =
- resource->poll_context;
- ae_resource_entries[reindex].poll_data.context = NULL;
- event.data.ptr = &ae_resource_entries[reindex].poll_data;
- event.events = EPOLLIN;
- ret = epoll_ctl(efd, EPOLL_CTL_ADD,
- ae_resource_entries[reindex].poll_data.pipe_fds[0], &event);
- if(ret < 0)
- {
- triton_err(triton_log_default, "Error: could not epoll fd for resource polling.\n");
- return(TRITON_ERR_EPOLL);
-
- }
-
- ae_resource_entries[reindex].id = AE_RESOURCE_IDX2ID(reindex);
- ae_resource_entries[reindex].resource = resource;
- ae_resource_count++;
- *newid = AE_RESOURCE_IDX2ID(reindex);
- return TRITON_SUCCESS;
-}
-#endif /* __AESOP_EPOLL */
-
-#ifdef __AESOP_LIBEV
static void ev_break_cb(EV_P_ ev_async *w, int revents)
{
/* Break the loop. Note that ev_run() will still process all events
@@ -216,7 +107,6 @@ triton_ret_t ae_resource_register(struct ae_resource *resource, int *newid)
*newid = AE_RESOURCE_IDX2ID(reindex);
return TRITON_SUCCESS;
}
-#endif /* __AESOP_LIBEV */
void ae_resource_unregister(int id)
{
@@ -226,15 +116,7 @@ void ae_resource_unregister(int id)
* just assume that contexts are always closed before resources are
* unregistered?
*/
-#ifdef __AESOP_EPOLL
- epoll_ctl(efd, EPOLL_CTL_DEL,
- ae_resource_entries[idx].poll_data.pipe_fds[0], NULL);
- close(ae_resource_entries[idx].poll_data.pipe_fds[0]);
- close(ae_resource_entries[idx].poll_data.pipe_fds[1]);
-#endif
-#ifdef __AESOP_LIBEV
ev_async_stop(eloop, &ae_resource_entries[idx].poll_data.async);
-#endif
if(idx != (ae_resource_count -1))
{
@@ -245,92 +127,6 @@ void ae_resource_unregister(int id)
ae_resource_count--;
}
-#ifdef __AESOP_EPOLL
-
-/**
- * ae_poll_break() can be used to interrupt a currently executing ae_poll
- * call. This would typically be used in the linkage between c and aesop
- * functions to allow the c program to continue execution after the final
- * aesop callback has completed.
- */
-void ae_poll_break(ae_context_t context)
-{
- int write_pipe = -1;
- char onebyte;
-
- if(pthread_equal(ev_loop_thread, pthread_self()))
- {
- /* this was called from the event loop thread, so we know that it is
- * already awake
- */
- return;
- }
-
- if(context)
- {
- write_pipe = context->break_target.pipe_fds[1];
- }
- else
- {
- write_pipe = break_target.pipe_fds[1];
- }
-
- write(write_pipe, &onebyte, 1);
-}
-
-/**
- * ae_resource_request_poll() is used by a resource to inform aesop that the
- * resource needs to be polled.
- */
-/* TODO: think about race conditions. Need any locking here? */
-void ae_resource_request_poll(ae_context_t context, int resource_id)
-{
- int write_pipe = -1;
- int i;
- int ridx;
- char onebyte = '0';
-
- if(context)
- {
- /* find this resource in the context */
- for(i=0; i<context->resource_count; i++)
- {
- if(resource_id == context->resource_ids[i])
- {
- write_pipe = context->poll_data[i].pipe_fds[1];
- break;
- }
- }
- }
- else
- {
- /* find this resource in the global list */
- ridx = AE_RESOURCE_ID2IDX(resource_id);
- write_pipe = ae_resource_entries[ridx].poll_data.pipe_fds[1];
- }
-
- if(write_pipe < 0)
- {
- triton_err(triton_log_default, "Error: context %p is not configured to handle resource with id %d", context, resource_id);
- for(i=0; i<ae_resource_count; i++)
- {
- if(ae_resource_entries[i].id == resource_id)
- {
- triton_err(triton_log_default, "Consider adding the \"%s\" resource your aesop context.", ae_resource_entries[i].resource->resource_name);
- assert(0);
- }
- }
- triton_err(triton_log_default, "Error: resource_id %d is unknown to aesop. Are you using a resource that was not initialized?\n", resource_id);
- assert(0);
- }
-
- write(write_pipe, &onebyte, 1);
- return;
-}
-#endif /* __AESOP_EPOLL */
-
-#ifdef __AESOP_LIBEV
-
static void find_async_watcher(ae_context_t context, int resource_id, ev_async** async_out, struct ev_loop** loop_out)
{
ev_async* async = NULL;
@@ -430,7 +226,6 @@ void ae_resource_request_poll(ae_context_t context, int resource_id)
return;
}
-#endif /* __AESOP_LIBEV */
/**
* ae_cancel_op tries to cancel the operation with the given id. This
@@ -622,106 +417,6 @@ void ae_backtrace(void)
#include <assert.h>
-#ifdef __AESOP_EPOLL
-#define AE_PIPE_READ_SIZE 128
-
-triton_ret_t ae_poll(ae_context_t context, int millisecs)
-{
- triton_ret_t tret;
- int to_poll;
- int ret;
- struct epoll_event* events;
- int event_count;
- int i;
- struct ae_poll_data* poll_data;
-
- if(context)
- {
- /* use context specific epoll fd */
- to_poll = context->efd;
- event_count = context->resource_count + 1;
- }
- else
- {
- /* use global epoll fd */
- if(efd < 0)
- {
- /* nothing to poll yet */
- return(TRITON_SUCCESS);
- }
- to_poll = efd;
- event_count = ae_resource_count + 1;
- }
-
- events = malloc(sizeof(*events) * event_count);
- if(!events)
- {
- return(TRITON_ERR_NOMEM);
- }
-
- /* wait for a resource to indicate that it has something to do */
- event_count = epoll_wait(to_poll, events, event_count, millisecs);
-
-
- /* if interrupted, just exit and let the caller try again */
- if(event_count < 0 && errno == EINTR)
- {
- free(events);
- return(TRITON_SUCCESS);
- }
-
- /* general error */
- if(event_count < 0)
- {
- free(events);
- triton_err(triton_log_default, "Error: could not epoll_wait for resource polling.\n");
- return(TRITON_ERR_EPOLL);
- }
-
- /* this means that the epoll timed out without finding any work */
- if(event_count == 0)
- {
- free(events);
- return(TRITON_ERR_TIMEDOUT);
- }
-
- /* poll each resource that needs attention */
- for(i=0; i<event_count; i++)
- {
- char pipebuf[AE_PIPE_READ_SIZE];
-
- poll_data = (struct ae_poll_data*)events[i].data.ptr;
- assert(poll_data);
- /* empty the pipe (short reads are ok) */
- if(poll_data->pipe_fds[1] != 0) /* skip non-pipes */
- {
- do
- {
- ret = read(events[i].data.fd, pipebuf, AE_PIPE_READ_SIZE);
- } while(ret >= 1 && ret < AE_PIPE_READ_SIZE);
- }
-
- if(poll_data->poll_context)
- {
- tret = poll_data->poll_context(context);
- if(tret != TRITON_SUCCESS)
- {
- free(events);
- return(tret);
- }
- }
- else
- {
- /* we were just signalled to wake up; no work to do */
- }
- }
-
- free(events);
- return(TRITON_SUCCESS);
-}
-#endif /* __AESOP_EPOLL */
-
-#ifdef __AESOP_LIBEV
static void timeout_cb(EV_P_ ev_timer *w, int revents)
{
int* hit_timeout = (int*)w->data;
@@ -773,7 +468,6 @@ triton_ret_t ae_poll(ae_context_t context, int millisecs)
return(TRITON_SUCCESS);
}
-#endif /* __AESOP_LIBEV */
#include <stdarg.h>
@@ -785,10 +479,6 @@ triton_ret_t _ae_context_create(ae_context_t *context, const char *format __attr
ae_context_t c;
int i, j, reindex;
triton_ret_t ret;
-#ifdef __AESOP_EPOLL
- struct epoll_event event;
- int ep_ret;
-#endif
if(ae_context_count == AE_MAX_CONTEXTS)
{
@@ -811,7 +501,6 @@ triton_ret_t _ae_context_create(ae_context_t *context, const char *format __attr
return TRITON_ERR_NOMEM;
}
-#ifdef __AESOP_LIBEV
c->eloop = ev_loop_new(EVFLAG_AUTO);
if(!c->eloop)
{
@@ -822,43 +511,7 @@ triton_ret_t _ae_context_create(ae_context_t *context, const char *format __attr
}
ev_async_init(&c->eloop_breaker, ev_break_cb);
ev_async_start(c->eloop, &c->eloop_breaker);
-#endif
-#ifdef __AESOP_EPOLL
- c->efd = epoll_create(32);
- if(c->efd < 0)
- {
- triton_err(triton_log_default, "Error: could not create epoll fd for resource polling.\n");
- free(c->resource_ids);
- free(c->poll_data);
- return(TRITON_ERR_EPOLL);
- }
- ep_ret = pipe(c->break_target.pipe_fds);
- if(ep_ret < 0)
- {
- triton_err(triton_log_default, "Error: could not create pipe for resource polling.\n");
- close(c->efd);
- free(c->resource_ids);
- free(c->poll_data);
- return(TRITON_ERR_EPOLL);
- }
- fcntl(c->break_target.pipe_fds[0], F_SETFL, O_NONBLOCK);
- fcntl(c->break_target.pipe_fds[1], F_SETFL, O_NONBLOCK);
- c->break_target.context = c;
- c->break_target.poll_context = NULL;
- event.data.ptr = &c->break_target;
- event.events = EPOLLIN;
- ep_ret = epoll_ctl(c->efd, EPOLL_CTL_ADD, c->break_target.pipe_fds[0], &event);
- if(ep_ret < 0)
- {
- triton_err(triton_log_default, "Error: could not epoll fd for resource polling.\n");
- close(c->efd);
- close(c->break_target.pipe_fds[0]);
- close(c->break_target.pipe_fds[1]);
- free(c->resource_ids);
- free(c->poll_data);
- return(TRITON_ERR_EPOLL);
- }
-#endif
+
reindex = 0;
/* step through the resource names passed in and register the context with them */
@@ -874,20 +527,7 @@ triton_ret_t _ae_context_create(ae_context_t *context, const char *format __attr
{
if(!strcmp(ae_resource_entries[j].resource->resource_name, rname))
{
-#ifdef __AESOP_EPOLL
- ep_ret = pipe(c->poll_data[reindex].pipe_fds);
- if(ep_ret < 0)
- {
- /* TODO: clean up better here */
- triton_err(triton_log_default, "Error: could not create pipe for resource polling.\n");
- return(TRITON_ERR_EPOLL);
- }
- fcntl(c->poll_data[reindex].pipe_fds[0], F_SETFL, O_NONBLOCK);
- fcntl(c->poll_data[reindex].pipe_fds[1], F_SETFL, O_NONBLOCK);
-#endif
-#ifdef __AESOP_LIBEV
ev_async_init(&c->poll_data[reindex].async, ev_async_cb);
-#endif
c->poll_data[reindex].poll_context =
ae_resource_entries[j].poll_data.poll_context;
c->poll_data[reindex].context = c;
@@ -902,23 +542,7 @@ triton_ret_t _ae_context_create(ae_context_t *context, const char *format __attr
return ret;
}
}
-
-#ifdef __AESOP_EPOLL
- /* monitor the context-specific pipe */
- event.data.ptr = &c->poll_data[reindex];
- event.events = EPOLLIN;
- ep_ret = epoll_ctl(c->efd, EPOLL_CTL_ADD,
- c->poll_data[reindex].pipe_fds[0], &event);
- if(ep_ret < 0 && errno != EEXIST)
- {
- /* TODO: clean up better here */
- triton_err(triton_log_default, "Error: could not epoll fd for resource polling.\n");
- return(TRITON_ERR_EPOLL);
- }
-#endif
-#ifdef __AESOP_LIBEV
ev_async_start(c->eloop, &c->poll_data[reindex].async);
-#endif
c->resource_ids[reindex] = ae_resource_entries[j].id;
@@ -952,15 +576,7 @@ triton_ret_t ae_context_destroy(ae_context_t context)
{
ae_resource_entries[idx].resource->unregister_context(context);
}
-#ifdef __AESOP_EPOLL
- if(context->poll_data[i].pipe_fds[0] >= 0)
- close(context->poll_data[i].pipe_fds[0]);
- if(context->poll_data[i].pipe_fds[1] >= 0)
- close(context->poll_data[i].pipe_fds[1]);
-#endif
-#ifdef __AESOP_LIBEV
ev_async_stop(context->eloop, &context->poll_data[i].async);
-#endif
}
free(context->resource_ids);
free(context->poll_data);
@@ -968,12 +584,7 @@ triton_ret_t ae_context_destroy(ae_context_t context)
context->poll_data = NULL;
context->id = -1;
context->resource_count = -1;
-#ifdef __AESOP_EPOLL
- close(context->efd);
-#endif
-#ifdef __AESOP_LIBEV
ev_loop_destroy(context->eloop);
-#endif
return TRITON_SUCCESS;
}
@@ -1099,7 +710,7 @@ triton_ret_t ae_error_wrap_stack(struct ae_ctl *ctl, triton_ret_t parent)
return ret;
}
-#ifdef __AESOP_LIBEV
+
struct ev_loop * ae_resource_get_eloop(ae_context_t context)
{
if(!context)
@@ -1107,8 +718,6 @@ struct ev_loop * ae_resource_get_eloop(ae_context_t context)
else
return(context->eloop);
}
-#endif
-
/*
* Local variables:
diff --git a/code/src/aesop/resource.h b/code/src/aesop/resource.h
index 2a0bc53..b4d30b0 100644
--- a/code/src/aesop/resource.h
+++ b/code/src/aesop/resource.h
@@ -62,12 +62,10 @@ void ae_resource_unregister(int resource_id);
void ae_resource_request_poll(ae_context_t context, int resource_id);
/* Called by c programs to break ae_poll() calls once callbacks are complete */
void ae_poll_break(ae_context_t context);
-#ifdef __AESOP_LIBEV
/* this function is used by resources that want access to the event loop
* used by aesop for this context
*/
struct ev_loop * ae_resource_get_eloop(ae_context_t context);
-#endif
/* Contexts are created to allow separation of polling for different logical
* groups of operations. Don't use this function. Instead, use the associated
diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c
index 3b0f6f0..ba3ec76 100644
--- a/code/src/common/resources/aesocket/aesocket.c
+++ b/code/src/common/resources/aesocket/aesocket.c
@@ -8,36 +8,7 @@
#include <pthread.h>
#include <unistd.h>
-#ifdef __AESOP_LIBEV
#include "src/common/libev/ev.h"
-#endif
-#ifdef __AESOP_EPOLL
-#include <sys/epoll.h>
-#endif
-
-/* TODO: Hack: so that we can modify the pipe fd used by this resource
- * (resources normally don't have the definition of these structs)
- */
-#ifdef __AESOP_EPOLL
-struct ae_poll_data
-{
-#ifdef __AESOP_EPOLL
- int pipe_fds[2];
-#endif
-#ifdef __AESOP_LIBEV
- ev_async async;
-#endif
- triton_ret_t (*poll_context)(ae_context_t context);
- ae_context_t context;
-};
-
-struct ae_resource_entry
-{
- int id;
- struct ae_poll_data poll_data;
- struct ae_resource *resource;
-};
-#endif
struct ae_context
{
@@ -45,14 +16,8 @@ struct ae_context
int resource_count;
int* resource_ids;
struct ae_poll_data* poll_data;
-#ifdef __AESOP_EPOLL
- struct ae_poll_data break_target;
- int efd;
-#endif
-#ifdef __AESOP_LIBEV
struct ev_loop *eloop;
ev_async eloop_breaker;
-#endif
};
@@ -72,61 +37,16 @@ struct aesocket_op
triton_ret_t tret;
int fd;
int flags;
-#ifdef __AESOP_LIBEV
ev_io io;
-#endif
};
-#ifdef __AESOP_LIBEV
static ae_ops_t posted_oplist;
static ae_ops_t inflight_oplist;
static ae_ops_t cancelled_oplist;
static pthread_t event_loop_thread;
-#else
-static pthread_t epoll_thread;
-static int epoll_thread_running = 0;
-static int epfd = -1;
-
-static void* thread_fn(void* foo)
-{
- struct epoll_event events[64];
- int count;
- struct ae_op *op;
- struct aesocket_op *socket_op;
- int i;
- int ret;
-
- do
- {
- if(epoll_thread_running)
- count = epoll_wait(epfd, events, 64, -1);
- else
- count = epoll_wait(epfd, events, 64, 0);
-
- /* TODO: error handling */
- assert(count >= 0);
-
- for(i=0; i<count; i++)
- {
- op = (struct ae_op*)events[i].data.ptr;
- socket_op = ae_op_entry(op, struct aesocket_op, op);
-/* NOTE: this isn't necessary now because we are using one shot events */
-#if 0
- ret = epoll_ctl(epfd, EPOLL_CTL_DEL, socket_op->fd, NULL);
- /* TODO: error handling */
- assert(count >= 0);
-#endif
- ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS);
- }
- }while(epoll_thread_running);
-
- return(NULL);
-}
-#endif
static triton_mutex_t aesocket_mutex = TRITON_MUTEX_INITIALIZER;
-#ifdef __AESOP_LIBEV
static void aesocket_fd_ready(
EV_P_ ev_io * io,
int revents)
@@ -144,19 +64,13 @@ static void aesocket_fd_ready(
ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS);
return;
}
-#endif
ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
int mode)
{
struct ae_op *op;
struct aesocket_op *socket_op;
-#ifdef __AESOP_LIBEV
struct ev_loop *eloop;
-#else
- struct epoll_event event;
- int ret;
-#endif
if (!aesocket_opcache)
{
@@ -174,19 +88,13 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
ae_id_gen(triton_aesocket_resource_id, (intptr_t) op);
socket_op->tret = TRITON_SUCCESS;
socket_op->fd = fd;
-#ifdef __AESOP_LIBEV
socket_op->flags = (mode & AESOCKET_READ ? EV_READ : 0)
| (mode & AESOCKET_WRITE ? EV_WRITE : 0);
-#else
- socket_op->flags = (mode & AESOCKET_READ ? EPOLLIN : 0)
- | (mode & AESOCKET_WRITE ? EPOLLOUT : 0);
-#endif
assert(socket_op->flags && "Need to specify one of AESOCKET_READ|AESOCKET_WRITE");
*__ae_op_id = socket_op->op_id;
-#ifdef __AESOP_LIBEV
/* TODO: this is a temporary, dirty hack. If we believe that the
* resource is being invoked from the same thread that is running the
* event loop, then we don't have to worry about thread safety and we
@@ -212,28 +120,6 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
triton_mutex_unlock(&aesocket_mutex);
ae_resource_request_poll(op->ctx, triton_aesocket_resource_id);
}
-#else
- event.data.ptr = op;
- event.events = socket_op->flags;
- event.events |= EPOLLONESHOT;
-
- /* TODO: think about races and how to prevent them if any */
- /* TODO: this is a hack method to track which fds have been added to the set already, just for testing */
- assert(fd < MAX_FDS);
- if(!known_fds[fd])
- {
- ret = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event);
- known_fds[fd] = 1;
- }
- else
- {
- ret = epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &event);
- }
- if(ret < 0)
- {
- return(TRITON_ERR_EPOLL);
- }
-#endif
return TRITON_SUCCESS;
}
@@ -241,7 +127,6 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
static triton_ret_t triton_aesocket_poll(
ae_context_t context)
{
-#ifdef __AESOP_LIBEV
struct ae_op *op;
struct aesocket_op *socket_op;
struct ev_loop *eloop;
@@ -279,9 +164,6 @@ static triton_ret_t triton_aesocket_poll(
}
triton_mutex_unlock(&aesocket_mutex);
-#else
- thread_fn(NULL);
-#endif
return TRITON_SUCCESS;
}
@@ -291,7 +173,6 @@ static triton_ret_t triton_aesocket_cancel(
ae_context_t triton_ctx,
ae_op_id_t op_id)
{
-#ifdef __AESOP_LIBEV
int resource_id;
struct ae_op *op;
struct aesocket_op *socket_op;
@@ -333,43 +214,14 @@ static triton_ret_t triton_aesocket_cancel(
triton_mutex_unlock(&aesocket_mutex);
/* already cancelled */
}
-#else
- /* TODO: implement cancel in epoll version */
- assert(0);
-#endif
-
- return(TRITON_SUCCESS);
-}
-
-#ifdef __AESOP_EPOLL
-/* TODO: yet another dirty hack; I'm going to use this to reach into the
- * context and replace the pipe fd that epoll is watching with my own fd
- */
-static triton_ret_t triton_aesocket_register_context(ae_context_t context)
-{
- int i;
-
- for(i=0; i<context->resource_count; i++)
- {
- if(context->poll_data[i].poll_context == triton_aesocket_poll)
- break;
- }
- close(context->poll_data[i].pipe_fds[0]);
- close(context->poll_data[i].pipe_fds[1]);
- context->poll_data[i].pipe_fds[0] = epfd;
- context->poll_data[i].pipe_fds[1] = 0;
return(TRITON_SUCCESS);
}
-#endif
struct ae_resource triton_aesocket_resource = {
.resource_name = "aesocket",
.poll_context = triton_aesocket_poll,
.cancel = triton_aesocket_cancel,
-#ifdef __AESOP_EPOLL
- .register_context = triton_aesocket_register_context
-#endif
};
__attribute__ ((constructor))
@@ -390,13 +242,11 @@ triton_ret_t triton_aesocket_init(
triton_ret_t tret;
int ret;
-#ifdef __AESOP_LIBEV
event_loop_thread = pthread_self();
ae_ops_init(&posted_oplist);
ae_ops_init(&cancelled_oplist);
ae_ops_init(&inflight_oplist);
-#endif
tret = AE_OPCACHE_INIT(struct aesocket_op,
op,
@@ -406,24 +256,6 @@ triton_ret_t triton_aesocket_init(
{
return tret;
}
-#ifdef __AESOP_EPOLL
- epfd = epoll_create(32);
- if(epfd < 0)
- {
- ae_opcache_destroy(aesocket_opcache);
- return(TRITON_ERR_EPOLL);
- }
-#if 0
- epoll_thread_running = 1;
- ret = pthread_create(&epoll_thread, NULL, thread_fn, NULL);
- if(ret < 0)
- {
- ae_opcache_destroy(aesocket_opcache);
- close(epfd);
- return(TRITON_ERR_EPOLL);
- }
-#endif
-#endif
return ae_resource_register(&triton_aesocket_resource,
&triton_aesocket_resource_id);
@@ -432,13 +264,6 @@ triton_ret_t triton_aesocket_init(
void triton_aesocket_finalize(
void)
{
-#ifdef __AESOP_EPOLL
-#if 0
- epoll_thread_running = 0;
- pthread_join(epoll_thread, NULL);
-#endif
- close(epfd);
-#endif
ae_resource_unregister(triton_aesocket_resource_id);
ae_opcache_destroy(aesocket_opcache);
}
diff --git a/code/src/common/resources/timer/timer.c b/code/src/common/resources/timer/timer.c
index d5cce84..76fc0d2 100644
--- a/code/src/common/resources/timer/timer.c
+++ b/code/src/common/resources/timer/timer.c
@@ -11,30 +11,22 @@
#include "src/aesop/opcache.h"
#include "src/common/resources/timer/timer.h"
#include "src/common/triton-init.h"
-#ifdef __AESOP_LIBEV
#include "src/common/libev/ev.h"
-#endif
/* NOTES:
*
- * This resource uses the POSIX timer interface to implement an aesop timer
- * resource. The aesop callbacks are driven directly from the timer
- * notfication function.
+ * This resource sets timers in the aesop libev event loop.
+ *
+ * TODO: There are some unresolved thread safety issues here.
*/
#define TIMER_DEFAULT_SIZE 1024
static ae_opcache_t timer_opcache = NULL;
static int triton_timer_resource_id;
-#ifdef __AESOP_LIBEV
static ev_timer timer_watcher;
static struct ev_loop* timer_loop = NULL;
static void timer_cb(EV_P_ ev_timer *w, int revents);
-#else
-static timer_t timer_id;
-static struct sigevent evp;
-static void timer_notify(union sigval sv);
-#endif
struct timer_op
{
@@ -45,9 +37,6 @@ struct timer_op
};
static triton_mutex_t timer_mutex = TRITON_MUTEX_INITIALIZER;
static ae_ops_t timer_oplist;
-#if 0
-static ae_ops_t cancel_oplist;
-#endif
ae_define_post(triton_ret_t, triton_timer, int millisecs)
{
@@ -57,9 +46,6 @@ ae_define_post(triton_ret_t, triton_timer, int millisecs)
struct ae_op *op;
struct ae_op *iter, *safe, *holder;
struct timer_op *timer_op_iter;
-#ifndef __AESOP_LIBEV
- struct itimerspec tspec;
-#endif
if(!timer_opcache)
{
@@ -110,20 +96,11 @@ ae_define_post(triton_ret_t, triton_timer, int millisecs)
if(holder == op)
{
/* new head of queue; arm a new timer or modify the existing one */
-#ifdef __AESOP_LIBEV
if(timer_loop)
ev_timer_stop(timer_loop, &timer_watcher);
ev_timer_set(&timer_watcher, (((ev_tstamp)millisecs)/1000.0), 0);
timer_loop = ae_resource_get_eloop(op->ctx);
ev_timer_start(timer_loop, &timer_watcher);
-#else
- memset(&tspec, 0, sizeof(tspec));
- tspec.it_value.tv_sec = (int)(millisecs/1000);
- tspec.it_value.tv_nsec = (millisecs % 1000) * 1e6;
- ret = timer_settime(timer_id, 0, &tspec, NULL);
- /* TODO: error handling (cancel all remaining timers?) */
- assert(ret == 0);
-#endif
}
*__ae_op_id = top->op_id;
@@ -133,40 +110,11 @@ ae_define_post(triton_ret_t, triton_timer, int millisecs)
return TRITON_SUCCESS;
}
-static triton_ret_t triton_timer_poll(ae_context_t context)
-{
- struct ae_op *op;
- struct timer_op *top;
-
- /* there is nothing for a timer poll to do */
-#if 0
- /* harvest any timers that have been cancelled */
- triton_mutex_lock(&timer_mutex);
- while((op = ae_ops_dequeue(&cancel_oplist)))
- {
- triton_mutex_unlock(&timer_mutex);
-
- top = ae_op_entry(op, struct timer_op, op);
- assert(top->tret == TRITON_ERR_CANCELED);
- ae_opcache_complete_op(timer_opcache, op, triton_ret_t, top->tret);
- triton_mutex_lock(&timer_mutex);
- }
- triton_mutex_unlock(&timer_mutex);
-#endif
-
- return TRITON_SUCCESS;
-}
-
static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_id)
{
/* TODO: do we have to check for races here (trying to cancel an ae_op
* that no longer exists) , or does aesop do that for us?
*/
-
-#ifndef __AESOP_LIBEV
- struct itimerspec tspec;
- struct itimerspec old_tspec;
-#endif
int resource_id;
struct ae_op *op;
struct timer_op *top;
@@ -203,18 +151,6 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i
ctx = op->ctx;
triton_mutex_unlock(&timer_mutex);
ae_opcache_complete_op(timer_opcache, op, triton_ret_t, TRITON_ERR_CANCELED);
- /* deprecated: this logic handles cancelled timers by putting them on a
- * queue to be harvested on the next poll call.
- */
-#if 0
- /* move to a special queue of cancelled timers */
- ctx = op->ctx;
- ae_ops_enqueue(op, &cancel_oplist);
- /* request a poll for aesop to harvest the cancelled timer */
- ae_resource_request_poll(ctx, triton_timer_resource_id);
-
- triton_mutex_unlock(&timer_mutex);
-#endif
return TRITON_SUCCESS;
}
@@ -222,7 +158,6 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i
struct ae_resource triton_timer_resource =
{
.resource_name = "timer",
- .poll_context = triton_timer_poll,
.cancel = triton_timer_cancel
};
@@ -238,26 +173,9 @@ triton_ret_t triton_timer_init(void)
triton_ret_t tret;
int ret;
-#ifdef __AESOP_LIBEV
ev_init(&timer_watcher, timer_cb);
-#else
- memset(&evp, 0, sizeof(evp));
- evp.sigev_notify = SIGEV_THREAD;
- evp.sigev_value.sival_ptr = NULL;
- evp.sigev_notify_function = timer_notify;
-
- ret = timer_create(CLOCK_REALTIME, &evp, &timer_id);
- if(ret < 0)
- {
- triton_err(triton_log_default, "Error: failed to create timer.");
- return(TRITON_ERR_NOMEM);
- }
-#endif
ae_ops_init(&timer_oplist);
-#if 0
- ae_ops_init(&cancel_oplist);
-#endif
tret = AE_OPCACHE_INIT(struct timer_op, op, TIMER_DEFAULT_SIZE, &timer_opcache);
if(tret != TRITON_SUCCESS)
@@ -272,18 +190,10 @@ void triton_timer_finalize(void)
{
ae_resource_unregister(triton_timer_resource_id);
-#ifndef __AESOP_LIBEV
- timer_delete(timer_id);
-#endif
-
ae_opcache_destroy(timer_opcache);
}
-#ifdef __AESOP_LIBEV
static void timer_cb(EV_P_ ev_timer *w, int revents)
-#else
-static void timer_notify(union sigval sv)
-#endif
{
struct ae_op *gop;
struct timer_op *top;
@@ -292,11 +202,7 @@ static void timer_notify(union sigval sv)
int did_something = 0;
ae_context_t ctx;
int ret;
-#ifdef __AESOP_LIBEV
ev_tstamp tstamp;
-#else
- struct itimerspec tspec;
-#endif
triton_mutex_lock(&timer_mutex);
@@ -335,21 +241,12 @@ static void timer_notify(union sigval sv)
diff.tv_usec = 1;
}
-#ifdef __AESOP_LIBEV
tstamp = (ev_tstamp)diff.tv_sec + (ev_tstamp)diff.tv_usec / 1000000.0;
if(timer_loop)
ev_timer_stop(timer_loop, &timer_watcher);
ev_timer_set(&timer_watcher, tstamp, 0);
timer_loop = ae_resource_get_eloop(gop->ctx);
ev_timer_start(timer_loop, &timer_watcher);
-#else
- memset(&tspec, 0, sizeof(tspec));
- tspec.it_value.tv_sec = diff.tv_sec;
- tspec.it_value.tv_nsec = diff.tv_usec * 1e3;
- ret = timer_settime(timer_id, 0, &tspec, NULL);
- /* TODO: error handling (cancel all remaining timers?) */
- assert(ret == 0);
-#endif
}
triton_mutex_unlock(&timer_mutex);
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. d971682ce443fb65a5c569f0909d4010a83e9683
by noreply@mcs.anl.gov 27 Jul '11
by noreply@mcs.anl.gov 27 Jul '11
27 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via d971682ce443fb65a5c569f0909d4010a83e9683 (commit)
from 2e11d735678746e0944546f5e9d10194711f75f4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d971682ce443fb65a5c569f0909d4010a83e9683
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Wed Jul 27 12:12:21 2011 -0700
Remove op->cache_id
Since the opid structure was increased to 128 bit, the need for the
indirection through cache_id is no longer needed.
Now the op structure pointer is typically (but not required) stored
directly in the opid.
-----------------------------------------------------------------------
Summary of changes:
code/src/aesop/op.h | 14 ++++++++---
code/src/aesop/opcache.c | 19 +++++++--------
code/src/aesop/opcache.h | 13 +++++-----
code/src/aesop/parser/tests/blocking/btest-impl.c | 20 ++++++++--------
code/src/aesop/resource.c | 9 ++++---
code/src/aesop/resource.h | 4 +-
code/src/common/resources/aesocket/aesocket.c | 6 +---
.../resources/branch-threader/branch-threader.c | 2 +-
code/src/common/resources/timer/timer.c | 6 +---
code/src/net/mpi/mpi.c | 8 ++----
.../prototype/bdb-resource/bdb-resource.c | 24 ++++++++++----------
.../prototype/file-resource/file-resource.c | 20 +++++++---------
.../versioned-osd/prototype/tests/fake-resource.c | 7 +----
13 files changed, 73 insertions(+), 79 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/op.h b/code/src/aesop/op.h
index b1f2cc3..2ff6f61 100644
--- a/code/src/aesop/op.h
+++ b/code/src/aesop/op.h
@@ -7,8 +7,6 @@
#include <stdint.h>
-typedef uintptr_t cache_id_t;
-
typedef struct ae_op
{
void *callback;
@@ -16,7 +14,6 @@ typedef struct ae_op
void *user_ptr;
ae_hints_t *hints;
ae_context_t ctx;
- cache_id_t cache_id;
ae_list_link_t link;
} ae_op_t;
@@ -53,7 +50,6 @@ typedef struct ae_op
(_op)->user_ptr = NULL; \
(_op)->hints = NULL; \
(_op)->ctx = NULL; \
- (_op)->cache_id = 0; \
ae_ops_link_clear(_op); \
} while(0)
@@ -93,6 +89,16 @@ static inline ae_op_t *ae_ops_peek(ae_ops_t *queue)
#define ae_ops_insert_after(_new, _after, _ops) triton_list_insert_after(&(_new)->link, &(_after)->link, _ops)
#define ae_ops_insert_before(_new, _before, _ops) triton_list_insert_before(&(_new)->link, &(_before)->link, _ops)
+
+/*
+ * This function was added to simplify casting from an op_id to the op
+ * structure.
+ */
+static inline struct ae_op * intptr2op (intptr_t op)
+{
+ return (struct ae_op *) op;
+}
+
#endif
/*
diff --git a/code/src/aesop/opcache.c b/code/src/aesop/opcache.c
index 7c64003..0857720 100644
--- a/code/src/aesop/opcache.c
+++ b/code/src/aesop/opcache.c
@@ -1,11 +1,11 @@
-/* Don't try to do manual memory management */
-// #define TRITON_OPCACHE_MALLOC
-
#include <errno.h>
#include "src/aesop/aesop.h"
#include "src/aesop/opcache.h"
#include "src/common/triton-error.h"
+/* Don't try to do manual memory management */
+#define TRITON_OPCACHE_MALLOC
+
#define TRITON_OPCACHE_ARRAY_COUNT 32
/* UNUSED #define TRITON_OPCACHE_MAX_INDEX (0xFFFFFF) */
@@ -71,6 +71,8 @@ static triton_ret_t ae_opcache_double(ae_opcache_t cache)
return TRITON_SUCCESS;
}
+triton_ret_t ae_opcache_double_size(ae_opcache_t cache);
+
triton_ret_t ae_opcache_double_size(ae_opcache_t cache)
{
triton_ret_t ret;
@@ -121,8 +123,6 @@ struct ae_op *ae_opcache_get(ae_opcache_t cache)
op = (struct ae_op *) ( (char*) malloc (cache->typesize) +
cache->member_offset);
ae_op_clear(op);
- assert (sizeof (op->cache_id) >= sizeof (op));
- op->cache_id = (uintptr_t) op;
#else
int aind, count;
@@ -143,9 +143,6 @@ struct ae_op *ae_opcache_get(ae_opcache_t cache)
cache->member_offset);
ae_op_clear(op);
- assert (sizeof(op->cache_id) >= 4);
-
- op->cache_id = (aind << 25) | count;
++cache->count;
}
else
@@ -171,6 +168,7 @@ void ae_opcache_put(ae_opcache_t cache, struct ae_op *op)
return;
}
+/*
struct ae_op * ae_opcache_lookup(ae_opcache_t cache, cache_id_t id)
{
#ifdef TRITON_OPCACHE_MALLOC
@@ -178,10 +176,10 @@ struct ae_op * ae_opcache_lookup(ae_opcache_t cache, cache_id_t id)
#else
int aind, count;
- /* the code below assumes we have 32 bits available */
+ // the code below assumes we have 32 bits available
assert (sizeof (cache_id_t) >= 4);
- /* we get the array index from the top 6 bits */
+ // we get the array index from the top 6 bits
aind = (id >> 25);
count = id & 0xFFFFFF;
@@ -190,6 +188,7 @@ struct ae_op * ae_opcache_lookup(ae_opcache_t cache, cache_id_t id)
cache->member_offset);
#endif
}
+*/
/*
* Local variables:
diff --git a/code/src/aesop/opcache.h b/code/src/aesop/opcache.h
index 8d0a0a5..a4b1da0 100644
--- a/code/src/aesop/opcache.h
+++ b/code/src/aesop/opcache.h
@@ -48,13 +48,6 @@ struct ae_op *ae_opcache_get(ae_opcache_t cache);
*/
void ae_opcache_put(ae_opcache_t cache, struct ae_op *op);
-
-/**
- * Given the cache id, return the ae_op * associated with it
- */
-struct ae_op *ae_opcache_lookup(ae_opcache_t cache, cache_id_t id);
-
-
/* (Dries) Disabled these functions: They're not used at this time,
* and expose information we cannot guarantee to always have.
*/
@@ -75,6 +68,12 @@ int ae_opcache_size(ae_opcache_t cache);
* in the cache without needing to double the size.
*/
int ae_opcache_count(ae_opcache_t cache);
+
+/**
+ * Given the cache id, return the ae_op * associated with it
+ */
+struct ae_op *ae_opcache_lookup(ae_opcache_t cache, cache_id_t id);
+
#endif
diff --git a/code/src/aesop/parser/tests/blocking/btest-impl.c b/code/src/aesop/parser/tests/blocking/btest-impl.c
index 61e2f13..8174431 100644
--- a/code/src/aesop/parser/tests/blocking/btest-impl.c
+++ b/code/src/aesop/parser/tests/blocking/btest-impl.c
@@ -78,7 +78,7 @@ ae_define_post(int, tctest1, int *a)
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
bop->value = a;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ret = pthread_attr_init(&attr);
assert(ret == 0);
@@ -118,7 +118,7 @@ ae_define_post(int, tctest_random)
op = ae_opcache_get(test_opcache);
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
printf("tctest_random\n");
ret = pthread_attr_init(&attr);
@@ -141,7 +141,7 @@ ae_define_post(triton_ret_t, btest_fail10, int *a)
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
bop->value = a;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &list_fail10);
ae_resource_request_poll(op->ctx, btest_resource_id);
@@ -158,7 +158,7 @@ ae_define_post(int, btest1, int *a)
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
bop->value = a;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &list1);
ae_resource_request_poll(op->ctx, btest_resource_id);
@@ -175,7 +175,7 @@ ae_define_post(int, btest2, int *a)
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
bop->value = a;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &list2);
ae_resource_request_poll(op->ctx, btest_resource_id);
@@ -192,7 +192,7 @@ ae_define_post(int, btest3, int *a)
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
bop->value = a;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &list3);
ae_resource_request_poll(op->ctx, btest_resource_id);
@@ -209,7 +209,7 @@ ae_define_post(int, btest_sleep, int secs)
ae_op_fill(op);
bop = ae_op_entry(op, struct bsleep_op, op);
bop->sleep = secs;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &slist);
ae_resource_request_poll(op->ctx, btest_resource_id);
@@ -226,7 +226,7 @@ ae_define_post(int, btest_sleep_random)
ae_op_fill(op);
bop = ae_op_entry(op, struct bsleep_op, op);
bop->sleep = random() % 1000;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &srlist);
ae_resource_request_poll(op->ctx, btest_resource_id);
@@ -243,7 +243,7 @@ ae_define_post(int, btest_forever)
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
bop->value = NULL;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &flist);
ae_resource_request_poll(op->ctx, btest_resource_id);
@@ -260,7 +260,7 @@ ae_define_post(int, btest_random)
ae_op_fill(op);
bop = ae_op_entry(op, struct btest_op, op);
bop->value = NULL;
- bop->id = ae_id_gen(btest_resource_id, (uint64_t)(op->cache_id));
+ bop->id = ae_id_gen(btest_resource_id, (intptr_t) op);
*__ae_op_id = bop->id;
ae_ops_enqueue(op, &rlist);
ae_resource_request_poll(op->ctx, btest_resource_id);
diff --git a/code/src/aesop/resource.c b/code/src/aesop/resource.c
index 3f9fc11..bc4619f 100644
--- a/code/src/aesop/resource.c
+++ b/code/src/aesop/resource.c
@@ -457,7 +457,8 @@ triton_ret_t ae_cancel_op(ae_context_t context, ae_op_id_t op_id)
if(resource_id == 0)
{
- ctl = (struct ae_ctl *)(intptr_t)ae_id_lookup(op_id, NULL);
+ intptr_t tmp = ae_id_lookup (op_id, NULL);
+ ctl = (struct ae_ctl *) tmp;
if(!ctl)
{
/* No blocking operation associated with this op_id. Nothing to cancel. */
@@ -530,7 +531,7 @@ triton_ret_t ae_cancel_op(ae_context_t context, ae_op_id_t op_id)
}
}
-ae_op_id_t ae_id_gen(int resource_id, uint64_t ptr)
+ae_op_id_t ae_id_gen(int resource_id, intptr_t ptr)
{
ae_op_id_t newid;
newid.u = resource_id;
@@ -538,10 +539,10 @@ ae_op_id_t ae_id_gen(int resource_id, uint64_t ptr)
return newid;
}
-uint64_t ae_id_lookup(ae_op_id_t id, int *resource_id)
+intptr_t ae_id_lookup(ae_op_id_t id, int *resource_id)
{
if(resource_id) *resource_id = id.u;
- return id.l;
+ return (intptr_t) id.l;
}
struct op_id_entry
diff --git a/code/src/aesop/resource.h b/code/src/aesop/resource.h
index f0bd2a7..2a0bc53 100644
--- a/code/src/aesop/resource.h
+++ b/code/src/aesop/resource.h
@@ -39,8 +39,8 @@
__ret_type *__ae_retval, \
##__fargs)
-ae_op_id_t ae_id_gen(int resource_id, uint64_t ptr);
-uint64_t ae_id_lookup(ae_op_id_t id, int *resource_id);
+ae_op_id_t ae_id_gen(int resource_id, intptr_t ptr);
+intptr_t ae_id_lookup(ae_op_id_t id, int *resource_id);
/* The resource structure is defined by a given resource, and registered
* to the aesop management code during resource initialization.
diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c
index f0f677c..3b0f6f0 100644
--- a/code/src/common/resources/aesocket/aesocket.c
+++ b/code/src/common/resources/aesocket/aesocket.c
@@ -171,7 +171,7 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
socket_op = ae_op_entry(op, struct aesocket_op,
op);
socket_op->op_id =
- ae_id_gen(triton_aesocket_resource_id, (uint64_t) (op->cache_id));
+ ae_id_gen(triton_aesocket_resource_id, (intptr_t) op);
socket_op->tret = TRITON_SUCCESS;
socket_op->fd = fd;
#ifdef __AESOP_LIBEV
@@ -292,7 +292,6 @@ static triton_ret_t triton_aesocket_cancel(
ae_op_id_t op_id)
{
#ifdef __AESOP_LIBEV
- cache_id_t cache_id;
int resource_id;
struct ae_op *op;
struct aesocket_op *socket_op;
@@ -303,9 +302,8 @@ static triton_ret_t triton_aesocket_cancel(
*/
triton_mutex_lock(&aesocket_mutex);
- cache_id = ae_id_lookup(op_id, &resource_id);
+ op = intptr2op (ae_id_lookup(op_id, &resource_id));
assert(resource_id == triton_aesocket_resource_id);
- op = ae_opcache_lookup(aesocket_opcache, cache_id);
socket_op = ae_op_entry(op, struct aesocket_op,
op);
ctx = op->ctx;
diff --git a/code/src/common/resources/branch-threader/branch-threader.c b/code/src/common/resources/branch-threader/branch-threader.c
index a47236c..5ea174d 100644
--- a/code/src/common/resources/branch-threader/branch-threader.c
+++ b/code/src/common/resources/branch-threader/branch-threader.c
@@ -73,7 +73,7 @@ ae_ret_t aesop_branch_threader(void (*__ae_callback)(void *ptr), \
ae_op_fill(op);
a_op = ae_op_entry(op, struct abt_op, op);
- a_op->op_id = ae_id_gen(abt_resource_id, (uint64_t)(op->cache_id));
+ a_op->op_id = ae_id_gen(abt_resource_id, (intptr_t) op);
*__ae_op_id = a_op->op_id;
diff --git a/code/src/common/resources/timer/timer.c b/code/src/common/resources/timer/timer.c
index 574edb4..d5cce84 100644
--- a/code/src/common/resources/timer/timer.c
+++ b/code/src/common/resources/timer/timer.c
@@ -71,7 +71,7 @@ ae_define_post(triton_ret_t, triton_timer, int millisecs)
ae_op_fill(op);
top = ae_op_entry(op, struct timer_op, op);
- top->op_id = ae_id_gen(triton_timer_resource_id, (uint64_t)(op->cache_id));
+ top->op_id = ae_id_gen(triton_timer_resource_id, (uintptr_t) op);
top->tret = TRITON_SUCCESS;
adjust.tv_sec = (int)(millisecs / 1e3);
@@ -167,7 +167,6 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i
struct itimerspec tspec;
struct itimerspec old_tspec;
#endif
- cache_id_t cache_id;
int resource_id;
struct ae_op *op;
struct timer_op *top;
@@ -178,9 +177,8 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i
*/
triton_mutex_lock(&timer_mutex);
- cache_id = ae_id_lookup(op_id, &resource_id);
+ op = intptr2op (ae_id_lookup(op_id, &resource_id));
assert(resource_id == triton_timer_resource_id);
- op = ae_opcache_lookup(timer_opcache, cache_id);
/* should still be in an op list */
if(!ae_ops_exists(&timer_oplist, &op->link))
diff --git a/code/src/net/mpi/mpi.c b/code/src/net/mpi/mpi.c
index 8db4316..216ee6d 100644
--- a/code/src/net/mpi/mpi.c
+++ b/code/src/net/mpi/mpi.c
@@ -165,7 +165,7 @@ static int add_op(MPI_Request req,
ae_op_fill_with_params(op, callback, up, hints, ctx);
- mpi_op->op_id = ae_id_gen(mpi_resource_id, (uint64_t)(op->cache_id));
+ mpi_op->op_id = ae_id_gen(mpi_resource_id, (uintptr_t) op);
mpi_op->request = req;
*op_id = mpi_op->op_id;
@@ -597,7 +597,6 @@ static triton_ret_t triton_mpi_poll(ae_context_t ctx)
static triton_ret_t triton_mpi_cancel(ae_context_t ctx, ae_op_id_t op_id)
{
- cache_id_t cache_id;
int resource_id, ret;
struct ae_op *op;
struct mpi_op *mpi_op;
@@ -607,10 +606,9 @@ static triton_ret_t triton_mpi_cancel(ae_context_t ctx, ae_op_id_t op_id)
if(!mpi_ctx)
return(TRITON_ERR_INVAL);
- cache_id = ae_id_lookup(op_id, &resource_id);
- assert(resource_id == mpi_resource_id);
+ op = intptr2op (ae_id_lookup(op_id, &resource_id));
+
triton_mutex_lock(&mpi_ctx->oplist_mutex);
- op = ae_opcache_lookup(mpi_ctx->opcache, cache_id);
if(!ae_ops_exists(&mpi_ctx->posted_oplist, &op->link) &&
!ae_ops_exists(&mpi_ctx->inflight_oplist, &op->link))
{
diff --git a/code/src/versioned-osd/prototype/bdb-resource/bdb-resource.c b/code/src/versioned-osd/prototype/bdb-resource/bdb-resource.c
index eeab4ca..c292809 100644
--- a/code/src/versioned-osd/prototype/bdb-resource/bdb-resource.c
+++ b/code/src/versioned-osd/prototype/bdb-resource/bdb-resource.c
@@ -503,7 +503,7 @@ ae_define_post(triton_ret_t, bdb_txn_begin,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.txn_begin.env = env;
b_op->u.txn_begin.parent = parent;
b_op->u.txn_begin.tid = tid;
@@ -529,7 +529,7 @@ ae_define_post(triton_ret_t, bdb_log_flush,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.log_flush.env = env;
b_op->u.log_flush.lsn = lsn;
b_op->work_fn = log_flush_work_fn;
@@ -572,7 +572,7 @@ ae_define_post(triton_ret_t, bdb_txn_checkpoint,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.txn_checkpoint.env = env;
b_op->u.txn_checkpoint.kbyte = kbyte;
b_op->u.txn_checkpoint.min = min;
@@ -639,7 +639,7 @@ ae_define_post(triton_ret_t, bdb_txn_commit,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.txn_commit.tid = tid;
b_op->u.txn_commit.flags = flags;
b_op->work_fn = txn_commit_work_fn;
@@ -680,7 +680,7 @@ ae_define_post(triton_ret_t, bdb_txn_abort,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.txn_abort.tid = tid;
b_op->work_fn = txn_abort_work_fn;
b_op->cleanup_fn = NULL;
@@ -729,7 +729,7 @@ ae_define_post(triton_ret_t, bdb_get,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.get.db = db;
b_op->u.get.txnid = txnid;
b_op->u.get.key = key;
@@ -778,7 +778,7 @@ ae_define_post(triton_ret_t, bdb_cursor_get,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.cursor_get.DBcursor = DBcursor;
b_op->u.cursor_get.key = key;
b_op->u.cursor_get.data = data;
@@ -823,7 +823,7 @@ ae_define_post(triton_ret_t, bdb_cursor_del,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.cursor_del.DBcursor = DBcursor;
b_op->u.cursor_del.flags = flags;
b_op->work_fn = cursor_del_work_fn;
@@ -863,7 +863,7 @@ ae_define_post(triton_ret_t, bdb_cursor_close,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.cursor_close.DBcursor = DBcursor;
b_op->work_fn = cursor_close_work_fn;
b_op->cleanup_fn = NULL;
@@ -905,7 +905,7 @@ ae_define_post(triton_ret_t, bdb_put,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.put.db = db;
b_op->u.put.txnid = txnid;
b_op->u.put.key = key;
@@ -954,7 +954,7 @@ ae_define_post(triton_ret_t, bdb_del,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.del.db = db;
b_op->u.del.txnid = txnid;
b_op->u.del.key = key;
@@ -1001,7 +1001,7 @@ ae_define_post(triton_ret_t, bdb_cursor,
ae_op_fill(op);
b_op = ae_op_entry(op, struct bdb_op, op);
- b_op->op_id = ae_id_gen(triton_bdb_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_bdb_resource_id, (intptr_t) op);
b_op->u.cursor.db = db;
b_op->u.cursor.txnid = txnid;
b_op->u.cursor.cursorp = cursorp;
diff --git a/code/src/versioned-osd/prototype/file-resource/file-resource.c b/code/src/versioned-osd/prototype/file-resource/file-resource.c
index 9bd15a2..20a7e24 100644
--- a/code/src/versioned-osd/prototype/file-resource/file-resource.c
+++ b/code/src/versioned-osd/prototype/file-resource/file-resource.c
@@ -295,16 +295,14 @@ static triton_ret_t file_poll(ae_context_t context)
*/
static triton_ret_t file_cancel(ae_context_t triton_ctx, ae_op_id_t op_id)
{
- cache_id_t cache_id;
int resource_id;
triton_mutex_lock(&file_mutex);
struct ae_op *op;
struct file_op *f_op;
- cache_id = ae_id_lookup(op_id, &resource_id);
+ op = intptr2op(ae_id_lookup(op_id, &resource_id));
assert(resource_id == triton_file_resource_id);
- op = ae_opcache_lookup(file_opcache, cache_id);
f_op = ae_op_entry(op, struct file_op, op);
#if 0
ae_ops_del(op);
@@ -404,7 +402,7 @@ ae_define_post(triton_ret_t, file_open,
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.open.fd = fd;
f_op->u.open.pathname = pathname;
f_op->u.open.flags = flags;
@@ -449,7 +447,7 @@ ae_define_post(triton_ret_t, file_fsync, int fd)
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.fsync.fd = fd;
f_op->work_fn = fsync_work_fn;
f_op->cleanup_fn = NULL;
@@ -469,7 +467,7 @@ ae_define_post(triton_ret_t, file_fdatasync, int fd)
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.fdatasync.fd = fd;
f_op->work_fn = fdatasync_work_fn;
f_op->cleanup_fn = NULL;
@@ -489,7 +487,7 @@ ae_define_post(triton_ret_t, file_close, int fd)
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.close.fd = fd;
f_op->work_fn = close_work_fn;
f_op->cleanup_fn = NULL;
@@ -574,7 +572,7 @@ ae_define_post(triton_ret_t, file_fstat,
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.fstat.fd = fd;
f_op->u.fstat.buf = buf;
f_op->work_fn = fstat_work_fn;
@@ -617,7 +615,7 @@ ae_define_post(triton_ret_t, file_ftruncate,
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.ftruncate.fd = fd;
f_op->u.ftruncate.length = length;
f_op->work_fn = ftruncate_work_fn;
@@ -662,7 +660,7 @@ ae_define_post(triton_ret_t, file_pwrite,
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.pwrite.fd = fd;
f_op->u.pwrite.buf = buf;
f_op->u.pwrite.count = count;
@@ -718,7 +716,7 @@ ae_define_post(triton_ret_t, file_pread,
ae_op_fill(op);
f_op = ae_op_entry(op, struct file_op, op);
- f_op->op_id = ae_id_gen(triton_file_resource_id, (uint64_t)(op->cache_id));
+ f_op->op_id = ae_id_gen(triton_file_resource_id, (intptr_t) op);
f_op->u.pread.fd = fd;
f_op->u.pread.buf = buf;
f_op->u.pread.count = count;
diff --git a/code/src/versioned-osd/prototype/tests/fake-resource.c b/code/src/versioned-osd/prototype/tests/fake-resource.c
index b3aefae..136a52a 100644
--- a/code/src/versioned-osd/prototype/tests/fake-resource.c
+++ b/code/src/versioned-osd/prototype/tests/fake-resource.c
@@ -118,16 +118,13 @@ static triton_ret_t fake_poll_thread_per_op(ae_context_t context)
*/
static triton_ret_t fake_cancel(ae_context_t triton_ctx, ae_op_id_t op_id)
{
- cache_id_t cache_id;
int resource_id;
triton_mutex_lock(&fake_mutex);
struct ae_op *op;
struct fake_op *b_op;
- cache_id = ae_id_lookup(op_id, &resource_id);
+ op = intptr2op (ae_id_lookup(op_id, &resource_id));
assert(resource_id == triton_fake_resource_id);
-
- op = ae_opcache_lookup(fake_opcache, cache_id);
b_op = ae_op_entry(op, struct fake_op, op);
#if 0
ae_ops_del(op);
@@ -190,7 +187,7 @@ ae_define_post(triton_ret_t, fake_fn1,
ae_op_fill(op);
b_op = ae_op_entry(op, struct fake_op, op);
- b_op->op_id = ae_id_gen(triton_fake_resource_id, (uint64_t)(op->cache_id));
+ b_op->op_id = ae_id_gen(triton_fake_resource_id, (intptr_t) op);
b_op->u.fn1.x = x;
b_op->work_fn = fn1_work_fn;
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 2e11d735678746e0944546f5e9d10194711f75f4
by noreply@mcs.anl.gov 26 Jul '11
by noreply@mcs.anl.gov 26 Jul '11
26 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 2e11d735678746e0944546f5e9d10194711f75f4 (commit)
from 52e103775e4a903e8d15bc3d8fcbe051a70203fa (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2e11d735678746e0944546f5e9d10194711f75f4
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Tue Jul 26 14:36:05 2011 -0700
Fix bug in triton_debug when using -DNDEBUG
-----------------------------------------------------------------------
Summary of changes:
code/src/common/triton-debug.h | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
Diff of changes:
diff --git a/code/src/common/triton-debug.h b/code/src/common/triton-debug.h
index 44ecf26..72e17c4 100644
--- a/code/src/common/triton-debug.h
+++ b/code/src/common/triton-debug.h
@@ -121,8 +121,8 @@ static inline int triton_debug_enabled(triton_debug_mask_t mask)
}
#else
-#define triton_debug(mask, message, ...) do { } while 0
-#define triton_debug_brief(mask, message, ...) do { } while 0
+#define triton_debug(mask, message, ...) do { } while (0)
+#define triton_debug_brief(mask, message, ...) do { } while (0)
#define triton_debug_enabled(mask) 0
#endif
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 52e103775e4a903e8d15bc3d8fcbe051a70203fa
by noreply@mcs.anl.gov 26 Jul '11
by noreply@mcs.anl.gov 26 Jul '11
26 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 52e103775e4a903e8d15bc3d8fcbe051a70203fa (commit)
via 34f9f7cec3ad7349f471eb79fea9a12a077defc8 (commit)
via 60c3c9e926f637ed5f13c643dc96d11a12e0282c (commit)
via 011c6f6a6a9fafa2916dff9b670a05a40b86eb68 (commit)
from e8a8acae99f89ee131aa4d77a846b8512b58a4ec (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 52e103775e4a903e8d15bc3d8fcbe051a70203fa
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Tue Jul 26 12:30:04 2011 -0700
By default, keep old opcache behaviour
commit 34f9f7cec3ad7349f471eb79fea9a12a077defc8
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Tue Jul 26 12:27:49 2011 -0700
Modify opcache
- Add mode where the opcache is not doing manual memory management
- Simplify opcache API (remove unused functions)
commit 60c3c9e926f637ed5f13c643dc96d11a12e0282c
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Tue Jul 26 12:27:29 2011 -0700
Unused define
commit 011c6f6a6a9fafa2916dff9b670a05a40b86eb68
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Tue Jul 26 12:26:14 2011 -0700
Introduce cache_id_t type
There was a lot of confusion about what the cache_id field (in the op
structure) was. Introduce typedef and fix where needed.
-----------------------------------------------------------------------
Summary of changes:
code/src/aesop/op.h | 6 ++-
code/src/aesop/opcache.c | 52 +++++++++++++++++---
code/src/aesop/opcache.h | 39 +++++++++++++--
code/src/common/resources/aesocket/aesocket.c | 5 +-
code/src/common/resources/timer/timer.c | 5 +-
code/src/net/mpi/mpi.c | 4 +-
.../prototype/file-resource/file-resource.c | 5 +-
.../versioned-osd/prototype/tests/fake-resource.c | 5 +-
8 files changed, 97 insertions(+), 24 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/op.h b/code/src/aesop/op.h
index 850877a..b1f2cc3 100644
--- a/code/src/aesop/op.h
+++ b/code/src/aesop/op.h
@@ -5,6 +5,10 @@
#include "src/aesop/aesop.h"
#include "src/aesop/ae-list.h"
+#include <stdint.h>
+
+typedef uintptr_t cache_id_t;
+
typedef struct ae_op
{
void *callback;
@@ -12,7 +16,7 @@ typedef struct ae_op
void *user_ptr;
ae_hints_t *hints;
ae_context_t ctx;
- int cache_id;
+ cache_id_t cache_id;
ae_list_link_t link;
} ae_op_t;
diff --git a/code/src/aesop/opcache.c b/code/src/aesop/opcache.c
index 3bfb2a3..7c64003 100644
--- a/code/src/aesop/opcache.c
+++ b/code/src/aesop/opcache.c
@@ -1,3 +1,5 @@
+/* Don't try to do manual memory management */
+// #define TRITON_OPCACHE_MALLOC
#include <errno.h>
#include "src/aesop/aesop.h"
@@ -5,16 +7,18 @@
#include "src/common/triton-error.h"
#define TRITON_OPCACHE_ARRAY_COUNT 32
-#define TRITON_OPCACHE_MAX_INDEX (0xFFFFFF)
+/* UNUSED #define TRITON_OPCACHE_MAX_INDEX (0xFFFFFF) */
struct ae_opcache
{
+#ifndef TRITON_OPCACHE_MALLOC
void *array[TRITON_OPCACHE_ARRAY_COUNT];
int array_count;
int size;
int count;
triton_mutex_t mutex;
ae_ops_t free_list;
+#endif
int typesize;
int member_offset;
};
@@ -27,6 +31,8 @@ triton_ret_t ae_opcache_init(int typesize, int member_offset, int init_size, ae_
{
return TRITON_ERR_NOMEM;
}
+
+#ifndef TRITON_OPCACHE_MALLOC
c->size = init_size;
c->array_count = 1;
c->array[0] = malloc(typesize * init_size);
@@ -35,15 +41,18 @@ triton_ret_t ae_opcache_init(int typesize, int member_offset, int init_size, ae_
free(c);
return TRITON_ERR_NOMEM;
}
- c->typesize = typesize;
- c->member_offset = member_offset;
c->count = 0;
- triton_mutex_init(&c->mutex, NULL);
ae_ops_init(&(c->free_list));
+ triton_mutex_init(&c->mutex, NULL);
+#endif
+
+ c->typesize = typesize;
+ c->member_offset = member_offset;
*cache = c;
return TRITON_SUCCESS;
}
+#ifndef TRITON_OPCACHE_MALLOC
static triton_ret_t ae_opcache_double(ae_opcache_t cache)
{
int i;
@@ -70,9 +79,11 @@ triton_ret_t ae_opcache_double_size(ae_opcache_t cache)
triton_mutex_unlock(&cache->mutex);
return ret;
}
+#endif
void ae_opcache_destroy(ae_opcache_t cache)
{
+#ifndef TRITON_OPCACHE_MALLOC
int i;
triton_mutex_lock(&cache->mutex);
for(i = 0; i < cache->array_count; ++i)
@@ -80,16 +91,18 @@ void ae_opcache_destroy(ae_opcache_t cache)
free(cache->array[i]);
}
triton_mutex_unlock(&cache->mutex);
+#endif
free(cache);
return;
}
-int ae_opcache_size(ae_opcache_t cache)
+#if 0
+static int ae_opcache_size(ae_opcache_t cache)
{
return cache->size;
}
-int ae_opcache_count(ae_opcache_t cache)
+static int ae_opcache_count(ae_opcache_t cache)
{
int count;
@@ -99,11 +112,19 @@ int ae_opcache_count(ae_opcache_t cache)
return count;
}
+#endif
struct ae_op *ae_opcache_get(ae_opcache_t cache)
{
- int aind, count;
struct ae_op *op;
+#ifdef TRITON_OPCACHE_MALLOC
+ op = (struct ae_op *) ( (char*) malloc (cache->typesize) +
+ cache->member_offset);
+ ae_op_clear(op);
+ assert (sizeof (op->cache_id) >= sizeof (op));
+ op->cache_id = (uintptr_t) op;
+#else
+ int aind, count;
triton_mutex_lock(&cache->mutex);
if(ae_ops_empty(&cache->free_list))
@@ -121,6 +142,9 @@ struct ae_op *ae_opcache_get(ae_opcache_t cache)
(count * cache->typesize) +
cache->member_offset);
ae_op_clear(op);
+
+ assert (sizeof(op->cache_id) >= 4);
+
op->cache_id = (aind << 25) | count;
++cache->count;
}
@@ -130,22 +154,33 @@ struct ae_op *ae_opcache_get(ae_opcache_t cache)
}
triton_mutex_unlock(&cache->mutex);
assert(op);
+#endif
return op;
}
void ae_opcache_put(ae_opcache_t cache, struct ae_op *op)
{
+#ifdef TRITON_OPCACHE_MALLOC
+ free ((char*) op - cache->member_offset);
+#else
triton_mutex_lock(&cache->mutex);
ae_ops_enqueue(op, &cache->free_list);
triton_mutex_unlock(&cache->mutex);
+#endif
return;
}
-struct ae_op *ae_opcache_lookup(ae_opcache_t cache, int id)
+struct ae_op * ae_opcache_lookup(ae_opcache_t cache, cache_id_t id)
{
+#ifdef TRITON_OPCACHE_MALLOC
+ return (struct ae_op *) id;
+#else
int aind, count;
+ /* the code below assumes we have 32 bits available */
+ assert (sizeof (cache_id_t) >= 4);
+
/* we get the array index from the top 6 bits */
aind = (id >> 25);
count = id & 0xFFFFFF;
@@ -153,6 +188,7 @@ struct ae_op *ae_opcache_lookup(ae_opcache_t cache, int id)
return (struct ae_op *)(((char *)cache->array[aind]) +
(count * cache->typesize) +
cache->member_offset);
+#endif
}
/*
diff --git a/code/src/aesop/opcache.h b/code/src/aesop/opcache.h
index 47b4aa9..8d0a0a5 100644
--- a/code/src/aesop/opcache.h
+++ b/code/src/aesop/opcache.h
@@ -1,4 +1,3 @@
-
#ifndef __OPCACHE_H__
#define __OPCACHE_H__
@@ -22,16 +21,46 @@ typedef struct ae_opcache *ae_opcache_t;
ae_opcache_put(__opcache, __op); \
} while(0)
-ae_ret_t ae_opcache_init(int typesize, int member_offset, int init_size, ae_opcache_t *cache);
-
-ae_ret_t ae_opcache_double_size(ae_opcache_t cache);
+/**
+ * Create an opcache.
+ * init_size is a hint and may be ignored.
+ */
+ae_ret_t ae_opcache_init(int typesize, int member_offset, int init_size,
+ ae_opcache_t *cache);
+
+/**
+ * Destroy the given opcache.
+ * Note that all entries obtained from this cache are released and
+ * invalidated.
+ */
void ae_opcache_destroy(ae_opcache_t cache);
+/**
+ * Obtain an ae_op entry. The entry will have a valid
+ * op->cache_id
+ */
struct ae_op *ae_opcache_get(ae_opcache_t cache);
+
+/**
+ * Return ae_op entry to the cache
+ */
void ae_opcache_put(ae_opcache_t cache, struct ae_op *op);
+
+/**
+ * Given the cache id, return the ae_op * associated with it
+ */
+struct ae_op *ae_opcache_lookup(ae_opcache_t cache, cache_id_t id);
+
+
+/* (Dries) Disabled these functions: They're not used at this time,
+ * and expose information we cannot guarantee to always have.
+ */
+#if 0
+ae_ret_t ae_opcache_double_size(ae_opcache_t cache);
+
/**
* Size of the opcache array. This is the total size of the cache. As
* more in-use ops are pulled from the cache (ae_opcache_get), the cache
@@ -46,8 +75,8 @@ int ae_opcache_size(ae_opcache_t cache);
* in the cache without needing to double the size.
*/
int ae_opcache_count(ae_opcache_t cache);
+#endif
-struct ae_op *ae_opcache_lookup(ae_opcache_t cache, int id);
#endif
diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c
index f7fe093..f0f677c 100644
--- a/code/src/common/resources/aesocket/aesocket.c
+++ b/code/src/common/resources/aesocket/aesocket.c
@@ -292,7 +292,8 @@ static triton_ret_t triton_aesocket_cancel(
ae_op_id_t op_id)
{
#ifdef __AESOP_LIBEV
- int cache_id, resource_id;
+ cache_id_t cache_id;
+ int resource_id;
struct ae_op *op;
struct aesocket_op *socket_op;
ae_context_t ctx;
@@ -304,7 +305,7 @@ static triton_ret_t triton_aesocket_cancel(
cache_id = ae_id_lookup(op_id, &resource_id);
assert(resource_id == triton_aesocket_resource_id);
- op = ae_opcache_lookup(aesocket_opcache, (int) cache_id);
+ op = ae_opcache_lookup(aesocket_opcache, cache_id);
socket_op = ae_op_entry(op, struct aesocket_op,
op);
ctx = op->ctx;
diff --git a/code/src/common/resources/timer/timer.c b/code/src/common/resources/timer/timer.c
index 05ec0e5..574edb4 100644
--- a/code/src/common/resources/timer/timer.c
+++ b/code/src/common/resources/timer/timer.c
@@ -167,7 +167,8 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i
struct itimerspec tspec;
struct itimerspec old_tspec;
#endif
- int cache_id, resource_id;
+ cache_id_t cache_id;
+ int resource_id;
struct ae_op *op;
struct timer_op *top;
ae_context_t ctx;
@@ -179,7 +180,7 @@ static triton_ret_t triton_timer_cancel(ae_context_t triton_ctx, ae_op_id_t op_i
cache_id = ae_id_lookup(op_id, &resource_id);
assert(resource_id == triton_timer_resource_id);
- op = ae_opcache_lookup(timer_opcache, (int)cache_id);
+ op = ae_opcache_lookup(timer_opcache, cache_id);
/* should still be in an op list */
if(!ae_ops_exists(&timer_oplist, &op->link))
diff --git a/code/src/net/mpi/mpi.c b/code/src/net/mpi/mpi.c
index b7c1229..8db4316 100644
--- a/code/src/net/mpi/mpi.c
+++ b/code/src/net/mpi/mpi.c
@@ -597,7 +597,7 @@ static triton_ret_t triton_mpi_poll(ae_context_t ctx)
static triton_ret_t triton_mpi_cancel(ae_context_t ctx, ae_op_id_t op_id)
{
- uint64_t cache_id;
+ cache_id_t cache_id;
int resource_id, ret;
struct ae_op *op;
struct mpi_op *mpi_op;
@@ -610,7 +610,7 @@ static triton_ret_t triton_mpi_cancel(ae_context_t ctx, ae_op_id_t op_id)
cache_id = ae_id_lookup(op_id, &resource_id);
assert(resource_id == mpi_resource_id);
triton_mutex_lock(&mpi_ctx->oplist_mutex);
- op = ae_opcache_lookup(mpi_ctx->opcache, (int)cache_id);
+ op = ae_opcache_lookup(mpi_ctx->opcache, cache_id);
if(!ae_ops_exists(&mpi_ctx->posted_oplist, &op->link) &&
!ae_ops_exists(&mpi_ctx->inflight_oplist, &op->link))
{
diff --git a/code/src/versioned-osd/prototype/file-resource/file-resource.c b/code/src/versioned-osd/prototype/file-resource/file-resource.c
index 8995de2..9bd15a2 100644
--- a/code/src/versioned-osd/prototype/file-resource/file-resource.c
+++ b/code/src/versioned-osd/prototype/file-resource/file-resource.c
@@ -295,7 +295,8 @@ static triton_ret_t file_poll(ae_context_t context)
*/
static triton_ret_t file_cancel(ae_context_t triton_ctx, ae_op_id_t op_id)
{
- int cache_id, resource_id;
+ cache_id_t cache_id;
+ int resource_id;
triton_mutex_lock(&file_mutex);
struct ae_op *op;
struct file_op *f_op;
@@ -303,7 +304,7 @@ static triton_ret_t file_cancel(ae_context_t triton_ctx, ae_op_id_t op_id)
cache_id = ae_id_lookup(op_id, &resource_id);
assert(resource_id == triton_file_resource_id);
- op = ae_opcache_lookup(file_opcache, (int)cache_id);
+ op = ae_opcache_lookup(file_opcache, cache_id);
f_op = ae_op_entry(op, struct file_op, op);
#if 0
ae_ops_del(op);
diff --git a/code/src/versioned-osd/prototype/tests/fake-resource.c b/code/src/versioned-osd/prototype/tests/fake-resource.c
index 9c87889..b3aefae 100644
--- a/code/src/versioned-osd/prototype/tests/fake-resource.c
+++ b/code/src/versioned-osd/prototype/tests/fake-resource.c
@@ -118,7 +118,8 @@ static triton_ret_t fake_poll_thread_per_op(ae_context_t context)
*/
static triton_ret_t fake_cancel(ae_context_t triton_ctx, ae_op_id_t op_id)
{
- int cache_id, resource_id;
+ cache_id_t cache_id;
+ int resource_id;
triton_mutex_lock(&fake_mutex);
struct ae_op *op;
struct fake_op *b_op;
@@ -126,7 +127,7 @@ static triton_ret_t fake_cancel(ae_context_t triton_ctx, ae_op_id_t op_id)
cache_id = ae_id_lookup(op_id, &resource_id);
assert(resource_id == triton_fake_resource_id);
- op = ae_opcache_lookup(fake_opcache, (int)cache_id);
+ op = ae_opcache_lookup(fake_opcache, cache_id);
b_op = ae_op_entry(op, struct fake_op, op);
#if 0
ae_ops_del(op);
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. e8a8acae99f89ee131aa4d77a846b8512b58a4ec
by noreply@mcs.anl.gov 26 Jul '11
by noreply@mcs.anl.gov 26 Jul '11
26 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via e8a8acae99f89ee131aa4d77a846b8512b58a4ec (commit)
from 3cb5da81075c513bbdc3831b730cd4a1615448b1 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit e8a8acae99f89ee131aa4d77a846b8512b58a4ec
Author: Philip Carns <carns(a)mcs.anl.gov>
Date: Tue Jul 26 10:26:26 2011 -0500
revert hack to reduce syscalls in libev
-----------------------------------------------------------------------
Summary of changes:
code/src/common/libev/ev_epoll.c | 6 ------
1 files changed, 0 insertions(+), 6 deletions(-)
Diff of changes:
diff --git a/code/src/common/libev/ev_epoll.c b/code/src/common/libev/ev_epoll.c
index 07a7a2e..5deb652 100644
--- a/code/src/common/libev/ev_epoll.c
+++ b/code/src/common/libev/ev_epoll.c
@@ -84,12 +84,6 @@ epoll_modify (EV_P_ int fd, int oev, int nev)
if (!nev)
return;
- /* TODO: this is temporary for testing purposes; avoid an extra epoll_ctl
- * add by trusting epoll not to lose track of sockets
- */
- if(oev == nev)
- return;
-
oldmask = anfds [fd].emask;
anfds [fd].emask = nev;
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 3cb5da81075c513bbdc3831b730cd4a1615448b1
by noreply@mcs.anl.gov 21 Jul '11
by noreply@mcs.anl.gov 21 Jul '11
21 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 3cb5da81075c513bbdc3831b730cd4a1615448b1 (commit)
via 2c97c468ffc688559eec356f438aa32038cfc48c (commit)
from 08b6cf4292576bf0fbeaa91f7a88f38c3a164a31 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3cb5da81075c513bbdc3831b730cd4a1615448b1
Author: Philip Carns <carns(a)mcs.anl.gov>
Date: Thu Jul 21 16:36:55 2011 -0500
more hacks: cascading epolls to avoid extra thread
- doesn't make much difference for performance, mainly just committing
this to save the code in case we want it
commit 2c97c468ffc688559eec356f438aa32038cfc48c
Author: Philip Carns <carns(a)mcs.anl.gov>
Date: Thu Jul 21 15:28:48 2011 -0500
initialize context in case caller doesn't specify
-----------------------------------------------------------------------
Summary of changes:
code/src/aesop/resource.c | 9 ++-
code/src/aesop/resource.h | 2 +-
code/src/common/resources/aesocket/aesocket.c | 85 +++++++++++++++++++++++--
3 files changed, 86 insertions(+), 10 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/resource.c b/code/src/aesop/resource.c
index 5ccba72..3f9fc11 100644
--- a/code/src/aesop/resource.c
+++ b/code/src/aesop/resource.c
@@ -692,10 +692,13 @@ triton_ret_t ae_poll(ae_context_t context, int millisecs)
poll_data = (struct ae_poll_data*)events[i].data.ptr;
assert(poll_data);
/* empty the pipe (short reads are ok) */
- do
+ if(poll_data->pipe_fds[1] != 0) /* skip non-pipes */
{
- ret = read(events[i].data.fd, pipebuf, AE_PIPE_READ_SIZE);
- } while(ret >= 1 && ret < AE_PIPE_READ_SIZE);
+ do
+ {
+ ret = read(events[i].data.fd, pipebuf, AE_PIPE_READ_SIZE);
+ } while(ret >= 1 && ret < AE_PIPE_READ_SIZE);
+ }
if(poll_data->poll_context)
{
diff --git a/code/src/aesop/resource.h b/code/src/aesop/resource.h
index d7c06d8..f0bd2a7 100644
--- a/code/src/aesop/resource.h
+++ b/code/src/aesop/resource.h
@@ -228,7 +228,7 @@ static void __main_cb(void *user_ptr, int t) \
} \
int main(int argc, char **argv) \
{ \
- ae_context_t __main_ctx; \
+ ae_context_t __main_ctx = NULL; \
ae_hints_t __main_hints; \
ae_op_id_t __main_opid; \
ae_ret_t ret; \
diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c
index b504fdf..f7fe093 100644
--- a/code/src/common/resources/aesocket/aesocket.c
+++ b/code/src/common/resources/aesocket/aesocket.c
@@ -15,6 +15,47 @@
#include <sys/epoll.h>
#endif
+/* TODO: Hack: so that we can modify the pipe fd used by this resource
+ * (resources normally don't have the definition of these structs)
+ */
+#ifdef __AESOP_EPOLL
+struct ae_poll_data
+{
+#ifdef __AESOP_EPOLL
+ int pipe_fds[2];
+#endif
+#ifdef __AESOP_LIBEV
+ ev_async async;
+#endif
+ triton_ret_t (*poll_context)(ae_context_t context);
+ ae_context_t context;
+};
+
+struct ae_resource_entry
+{
+ int id;
+ struct ae_poll_data poll_data;
+ struct ae_resource *resource;
+};
+#endif
+
+struct ae_context
+{
+ int id;
+ int resource_count;
+ int* resource_ids;
+ struct ae_poll_data* poll_data;
+#ifdef __AESOP_EPOLL
+ struct ae_poll_data break_target;
+ int efd;
+#endif
+#ifdef __AESOP_LIBEV
+ struct ev_loop *eloop;
+ ev_async eloop_breaker;
+#endif
+};
+
+
/* TODO: this is a hack for testing */
#define MAX_FDS 1024
char known_fds[MAX_FDS] = {0};
@@ -55,9 +96,13 @@ static void* thread_fn(void* foo)
int i;
int ret;
- while(epoll_thread_running)
+ do
{
- count = epoll_wait(epfd, events, 64, -1);
+ if(epoll_thread_running)
+ count = epoll_wait(epfd, events, 64, -1);
+ else
+ count = epoll_wait(epfd, events, 64, 0);
+
/* TODO: error handling */
assert(count >= 0);
@@ -73,7 +118,7 @@ static void* thread_fn(void* foo)
#endif
ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS);
}
- }
+ }while(epoll_thread_running);
return(NULL);
}
@@ -235,8 +280,7 @@ static triton_ret_t triton_aesocket_poll(
triton_mutex_unlock(&aesocket_mutex);
#else
- /* poll function not used in epoll version */
- assert(0);
+ thread_fn(NULL);
#endif
return TRITON_SUCCESS;
@@ -298,10 +342,35 @@ static triton_ret_t triton_aesocket_cancel(
return(TRITON_SUCCESS);
}
+#ifdef __AESOP_EPOLL
+/* TODO: yet another dirty hack; I'm going to use this to reach into the
+ * context and replace the pipe fd that epoll is watching with my own fd
+ */
+static triton_ret_t triton_aesocket_register_context(ae_context_t context)
+{
+ int i;
+
+ for(i=0; i<context->resource_count; i++)
+ {
+ if(context->poll_data[i].poll_context == triton_aesocket_poll)
+ break;
+ }
+ close(context->poll_data[i].pipe_fds[0]);
+ close(context->poll_data[i].pipe_fds[1]);
+ context->poll_data[i].pipe_fds[0] = epfd;
+ context->poll_data[i].pipe_fds[1] = 0;
+
+ return(TRITON_SUCCESS);
+}
+#endif
+
struct ae_resource triton_aesocket_resource = {
.resource_name = "aesocket",
.poll_context = triton_aesocket_poll,
- .cancel = triton_aesocket_cancel
+ .cancel = triton_aesocket_cancel,
+#ifdef __AESOP_EPOLL
+ .register_context = triton_aesocket_register_context
+#endif
};
__attribute__ ((constructor))
@@ -345,6 +414,7 @@ triton_ret_t triton_aesocket_init(
ae_opcache_destroy(aesocket_opcache);
return(TRITON_ERR_EPOLL);
}
+#if 0
epoll_thread_running = 1;
ret = pthread_create(&epoll_thread, NULL, thread_fn, NULL);
if(ret < 0)
@@ -354,6 +424,7 @@ triton_ret_t triton_aesocket_init(
return(TRITON_ERR_EPOLL);
}
#endif
+#endif
return ae_resource_register(&triton_aesocket_resource,
&triton_aesocket_resource_id);
@@ -363,8 +434,10 @@ void triton_aesocket_finalize(
void)
{
#ifdef __AESOP_EPOLL
+#if 0
epoll_thread_running = 0;
pthread_join(epoll_thread, NULL);
+#endif
close(epfd);
#endif
ae_resource_unregister(triton_aesocket_resource_id);
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 08b6cf4292576bf0fbeaa91f7a88f38c3a164a31
by noreply@mcs.anl.gov 21 Jul '11
by noreply@mcs.anl.gov 21 Jul '11
21 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 08b6cf4292576bf0fbeaa91f7a88f38c3a164a31 (commit)
from 3df48677eef229b7b3d9d34edcaea6966af5b95f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 08b6cf4292576bf0fbeaa91f7a88f38c3a164a31
Author: Philip Carns <carns(a)mcs.anl.gov>
Date: Thu Jul 21 15:10:09 2011 -0500
avoid repetitive add/delete of sockets from epoll
- this is just experimental code in the epoll version of aesocket, not
worth implementing cleanly right now
- use "oneshot" epoll events to make sure that events don't trigger
unless we have corresponding ops posted in the resource
-----------------------------------------------------------------------
Summary of changes:
code/src/common/resources/aesocket/aesocket.c | 28 ++++++++++++++++---------
1 files changed, 18 insertions(+), 10 deletions(-)
Diff of changes:
diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c
index f83360f..b504fdf 100644
--- a/code/src/common/resources/aesocket/aesocket.c
+++ b/code/src/common/resources/aesocket/aesocket.c
@@ -15,7 +15,9 @@
#include <sys/epoll.h>
#endif
-
+/* TODO: this is a hack for testing */
+#define MAX_FDS 1024
+char known_fds[MAX_FDS] = {0};
#define AESOCKET_DEFAULT_SIZE 1024
@@ -61,15 +63,14 @@ static void* thread_fn(void* foo)
for(i=0; i<count; i++)
{
- /* TODO: adding and removing sockets constantly from the epoll set isn't
- * great; it would be better if we could keep them in there persistently
- * and just modify the event type
- */
op = (struct ae_op*)events[i].data.ptr;
socket_op = ae_op_entry(op, struct aesocket_op, op);
+/* NOTE: this isn't necessary now because we are using one shot events */
+#if 0
ret = epoll_ctl(epfd, EPOLL_CTL_DEL, socket_op->fd, NULL);
/* TODO: error handling */
assert(count >= 0);
+#endif
ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS);
}
}
@@ -169,13 +170,20 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
#else
event.data.ptr = op;
event.events = socket_op->flags;
+ event.events |= EPOLLONESHOT;
- /* TODO: adding and removing sockets constantly from the epoll set isn't
- * great; it would be better if we could keep them in there persistently
- * and just modify the event type
- */
/* TODO: think about races and how to prevent them if any */
- ret = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event);
+ /* TODO: this is a hack method to track which fds have been added to the set already, just for testing */
+ assert(fd < MAX_FDS);
+ if(!known_fds[fd])
+ {
+ ret = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event);
+ known_fds[fd] = 1;
+ }
+ else
+ {
+ ret = epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &event);
+ }
if(ret < 0)
{
return(TRITON_ERR_EPOLL);
hooks/post-receive
--
Triton Repository
1
0
Triton Repository branch, master, updated. 3df48677eef229b7b3d9d34edcaea6966af5b95f
by noreply@mcs.anl.gov 20 Jul '11
by noreply@mcs.anl.gov 20 Jul '11
20 Jul '11
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Triton Repository".
The branch, master has been updated
via 3df48677eef229b7b3d9d34edcaea6966af5b95f (commit)
via 33a64e82c04bc2f99e5f88f1e11c581ccded085a (commit)
via cfc66224c3b71f1a19a07d780dd36db3e7f830a9 (commit)
from 20818919f70ed5f865fed2637be753a449d4cb1a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3df48677eef229b7b3d9d34edcaea6966af5b95f
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Jul 20 16:19:41 2011 -0400
experimental raw epoll support in aesocket
commit 33a64e82c04bc2f99e5f88f1e11c581ccded085a
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Jul 20 16:16:25 2011 -0400
fix ae_poll_break in epoll path
commit cfc66224c3b71f1a19a07d780dd36db3e7f830a9
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Jul 20 14:37:32 2011 -0400
update epoll code path in resource polling
-----------------------------------------------------------------------
Summary of changes:
code/src/aesop/resource.c | 115 ++++++++++++++++++++---
code/src/common/resources/aesocket/aesocket.c | 124 +++++++++++++++++++++++--
2 files changed, 217 insertions(+), 22 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/resource.c b/code/src/aesop/resource.c
index 35d86e9..5ccba72 100644
--- a/code/src/aesop/resource.c
+++ b/code/src/aesop/resource.c
@@ -44,6 +44,7 @@ static int ae_resource_count = 0;
static struct ae_resource_entry ae_resource_entries[AE_MAX_RESOURCES];
#ifdef __AESOP_EPOLL
static int efd = -1;
+struct ae_poll_data break_target;
#endif
#ifdef __AESOP_LIBEV
static struct ev_loop *eloop = NULL;
@@ -61,6 +62,7 @@ struct ae_context
int* resource_ids;
struct ae_poll_data* poll_data;
#ifdef __AESOP_EPOLL
+ struct ae_poll_data break_target;
int efd;
#endif
#ifdef __AESOP_LIBEV
@@ -81,13 +83,38 @@ triton_ret_t ae_resource_register(struct ae_resource *resource, int *newid)
if(efd < 0)
{
- /* epoll fd has not been created yet */
+ /* This is the first resource to be registered. Initialize the
+ * epoll fd and create a pipe that can be used to break the epoll
+ * wait.
+ */
efd = epoll_create(32);
if(efd < 0)
{
triton_err(triton_log_default, "Error: could not create epoll fd for resource polling.\n");
return(TRITON_ERR_EPOLL);
}
+ ret = pipe(break_target.pipe_fds);
+ if(ret < 0)
+ {
+ triton_err(triton_log_default, "Error: could not create pipe for resource polling.\n");
+ close(efd);
+ return(TRITON_ERR_EPOLL);
+ }
+ fcntl(break_target.pipe_fds[0], F_SETFL, O_NONBLOCK);
+ fcntl(break_target.pipe_fds[1], F_SETFL, O_NONBLOCK);
+ break_target.context = NULL;
+ break_target.poll_context = NULL;
+ event.data.ptr = &break_target;
+ event.events = EPOLLIN;
+ ret = epoll_ctl(efd, EPOLL_CTL_ADD, break_target.pipe_fds[0], &event);
+ if(ret < 0)
+ {
+ triton_err(triton_log_default, "Error: could not epoll fd for resource polling.\n");
+ close(efd);
+ close(break_target.pipe_fds[0]);
+ close(break_target.pipe_fds[1]);
+ return(TRITON_ERR_EPOLL);
+ }
}
if(ae_resource_count == AE_MAX_RESOURCES)
@@ -219,6 +246,38 @@ void ae_resource_unregister(int id)
}
#ifdef __AESOP_EPOLL
+
+/**
+ * ae_poll_break() can be used to interrupt a currently executing ae_poll
+ * call. This would typically be used in the linkage between c and aesop
+ * functions to allow the c program to continue execution after the final
+ * aesop callback has completed.
+ */
+void ae_poll_break(ae_context_t context)
+{
+ int write_pipe = -1;
+ char onebyte;
+
+ if(pthread_equal(ev_loop_thread, pthread_self()))
+ {
+ /* this was called from the event loop thread, so we know that it is
+ * already awake
+ */
+ return;
+ }
+
+ if(context)
+ {
+ write_pipe = context->break_target.pipe_fds[1];
+ }
+ else
+ {
+ write_pipe = break_target.pipe_fds[1];
+ }
+
+ write(write_pipe, &onebyte, 1);
+}
+
/**
* ae_resource_request_poll() is used by a resource to inform aesop that the
* resource needs to be polled.
@@ -579,7 +638,7 @@ triton_ret_t ae_poll(ae_context_t context, int millisecs)
{
/* use context specific epoll fd */
to_poll = context->efd;
- event_count = context->resource_count;
+ event_count = context->resource_count + 1;
}
else
{
@@ -590,7 +649,7 @@ triton_ret_t ae_poll(ae_context_t context, int millisecs)
return(TRITON_SUCCESS);
}
to_poll = efd;
- event_count = ae_resource_count;
+ event_count = ae_resource_count + 1;
}
events = malloc(sizeof(*events) * event_count);
@@ -602,6 +661,7 @@ triton_ret_t ae_poll(ae_context_t context, int millisecs)
/* wait for a resource to indicate that it has something to do */
event_count = epoll_wait(to_poll, events, event_count, millisecs);
+
/* if interrupted, just exit and let the caller try again */
if(event_count < 0 && errno == EINTR)
{
@@ -630,20 +690,25 @@ triton_ret_t ae_poll(ae_context_t context, int millisecs)
char pipebuf[AE_PIPE_READ_SIZE];
poll_data = (struct ae_poll_data*)events[i].data.ptr;
+ assert(poll_data);
/* empty the pipe (short reads are ok) */
do
{
- ret = read(poll_data->pipe_fds[0], pipebuf, AE_PIPE_READ_SIZE);
+ ret = read(events[i].data.fd, pipebuf, AE_PIPE_READ_SIZE);
} while(ret >= 1 && ret < AE_PIPE_READ_SIZE);
- /* we better not get data on this pipe if the resource doesn't
- * provide a poll function
- */
- assert(poll_data->poll_context);
- tret = poll_data->poll_context(context);
- if(tret != TRITON_SUCCESS)
+
+ if(poll_data->poll_context)
{
- free(events);
- return(tret);
+ tret = poll_data->poll_context(context);
+ if(tret != TRITON_SUCCESS)
+ {
+ free(events);
+ return(tret);
+ }
+ }
+ else
+ {
+ /* we were just signalled to wake up; no work to do */
}
}
@@ -763,6 +828,32 @@ triton_ret_t _ae_context_create(ae_context_t *context, const char *format __attr
free(c->poll_data);
return(TRITON_ERR_EPOLL);
}
+ ep_ret = pipe(c->break_target.pipe_fds);
+ if(ep_ret < 0)
+ {
+ triton_err(triton_log_default, "Error: could not create pipe for resource polling.\n");
+ close(c->efd);
+ free(c->resource_ids);
+ free(c->poll_data);
+ return(TRITON_ERR_EPOLL);
+ }
+ fcntl(c->break_target.pipe_fds[0], F_SETFL, O_NONBLOCK);
+ fcntl(c->break_target.pipe_fds[1], F_SETFL, O_NONBLOCK);
+ c->break_target.context = c;
+ c->break_target.poll_context = NULL;
+ event.data.ptr = &c->break_target;
+ event.events = EPOLLIN;
+ ep_ret = epoll_ctl(c->efd, EPOLL_CTL_ADD, c->break_target.pipe_fds[0], &event);
+ if(ep_ret < 0)
+ {
+ triton_err(triton_log_default, "Error: could not epoll fd for resource polling.\n");
+ close(c->efd);
+ close(c->break_target.pipe_fds[0]);
+ close(c->break_target.pipe_fds[1]);
+ free(c->resource_ids);
+ free(c->poll_data);
+ return(TRITON_ERR_EPOLL);
+ }
#endif
reindex = 0;
diff --git a/code/src/common/resources/aesocket/aesocket.c b/code/src/common/resources/aesocket/aesocket.c
index 32b2fe6..f83360f 100644
--- a/code/src/common/resources/aesocket/aesocket.c
+++ b/code/src/common/resources/aesocket/aesocket.c
@@ -5,12 +5,16 @@
#include "src/common/triton-init.h"
#include <assert.h>
+#include <pthread.h>
+#include <unistd.h>
-#ifndef __AESOP_LIBEV
-#error Socket resource requires libev for now!
+#ifdef __AESOP_LIBEV
+#include "src/common/libev/ev.h"
+#endif
+#ifdef __AESOP_EPOLL
+#include <sys/epoll.h>
#endif
-#include "src/common/libev/ev.h"
#define AESOCKET_DEFAULT_SIZE 1024
@@ -18,12 +22,6 @@
static ae_opcache_t aesocket_opcache = NULL;
static int triton_aesocket_resource_id;
-static ae_ops_t posted_oplist;
-static ae_ops_t inflight_oplist;
-static ae_ops_t cancelled_oplist;
-
-static pthread_t event_loop_thread;
-
struct aesocket_op
{
ae_op_id_t op_id;
@@ -31,11 +29,58 @@ struct aesocket_op
triton_ret_t tret;
int fd;
int flags;
+#ifdef __AESOP_LIBEV
ev_io io;
+#endif
};
+#ifdef __AESOP_LIBEV
+static ae_ops_t posted_oplist;
+static ae_ops_t inflight_oplist;
+static ae_ops_t cancelled_oplist;
+static pthread_t event_loop_thread;
+#else
+static pthread_t epoll_thread;
+static int epoll_thread_running = 0;
+static int epfd = -1;
+
+static void* thread_fn(void* foo)
+{
+ struct epoll_event events[64];
+ int count;
+ struct ae_op *op;
+ struct aesocket_op *socket_op;
+ int i;
+ int ret;
+
+ while(epoll_thread_running)
+ {
+ count = epoll_wait(epfd, events, 64, -1);
+ /* TODO: error handling */
+ assert(count >= 0);
+
+ for(i=0; i<count; i++)
+ {
+ /* TODO: adding and removing sockets constantly from the epoll set isn't
+ * great; it would be better if we could keep them in there persistently
+ * and just modify the event type
+ */
+ op = (struct ae_op*)events[i].data.ptr;
+ socket_op = ae_op_entry(op, struct aesocket_op, op);
+ ret = epoll_ctl(epfd, EPOLL_CTL_DEL, socket_op->fd, NULL);
+ /* TODO: error handling */
+ assert(count >= 0);
+ ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS);
+ }
+ }
+
+ return(NULL);
+}
+#endif
+
static triton_mutex_t aesocket_mutex = TRITON_MUTEX_INITIALIZER;
+#ifdef __AESOP_LIBEV
static void aesocket_fd_ready(
EV_P_ ev_io * io,
int revents)
@@ -53,13 +98,19 @@ static void aesocket_fd_ready(
ae_opcache_complete_op(aesocket_opcache, op, triton_ret_t, TRITON_SUCCESS);
return;
}
+#endif
ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
int mode)
{
struct ae_op *op;
struct aesocket_op *socket_op;
+#ifdef __AESOP_LIBEV
struct ev_loop *eloop;
+#else
+ struct epoll_event event;
+ int ret;
+#endif
if (!aesocket_opcache)
{
@@ -77,13 +128,19 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
ae_id_gen(triton_aesocket_resource_id, (uint64_t) (op->cache_id));
socket_op->tret = TRITON_SUCCESS;
socket_op->fd = fd;
+#ifdef __AESOP_LIBEV
socket_op->flags = (mode & AESOCKET_READ ? EV_READ : 0)
| (mode & AESOCKET_WRITE ? EV_WRITE : 0);
+#else
+ socket_op->flags = (mode & AESOCKET_READ ? EPOLLIN : 0)
+ | (mode & AESOCKET_WRITE ? EPOLLOUT : 0);
+#endif
assert(socket_op->flags && "Need to specify one of AESOCKET_READ|AESOCKET_WRITE");
*__ae_op_id = socket_op->op_id;
+#ifdef __AESOP_LIBEV
/* TODO: this is a temporary, dirty hack. If we believe that the
* resource is being invoked from the same thread that is running the
* event loop, then we don't have to worry about thread safety and we
@@ -109,6 +166,21 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
triton_mutex_unlock(&aesocket_mutex);
ae_resource_request_poll(op->ctx, triton_aesocket_resource_id);
}
+#else
+ event.data.ptr = op;
+ event.events = socket_op->flags;
+
+ /* TODO: adding and removing sockets constantly from the epoll set isn't
+ * great; it would be better if we could keep them in there persistently
+ * and just modify the event type
+ */
+ /* TODO: think about races and how to prevent them if any */
+ ret = epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &event);
+ if(ret < 0)
+ {
+ return(TRITON_ERR_EPOLL);
+ }
+#endif
return TRITON_SUCCESS;
}
@@ -116,7 +188,7 @@ ae_define_post(triton_ret_t, triton_aesocket_ready, int fd,
static triton_ret_t triton_aesocket_poll(
ae_context_t context)
{
-
+#ifdef __AESOP_LIBEV
struct ae_op *op;
struct aesocket_op *socket_op;
struct ev_loop *eloop;
@@ -154,6 +226,10 @@ static triton_ret_t triton_aesocket_poll(
}
triton_mutex_unlock(&aesocket_mutex);
+#else
+ /* poll function not used in epoll version */
+ assert(0);
+#endif
return TRITON_SUCCESS;
}
@@ -163,6 +239,7 @@ static triton_ret_t triton_aesocket_cancel(
ae_context_t triton_ctx,
ae_op_id_t op_id)
{
+#ifdef __AESOP_LIBEV
int cache_id, resource_id;
struct ae_op *op;
struct aesocket_op *socket_op;
@@ -205,6 +282,10 @@ static triton_ret_t triton_aesocket_cancel(
triton_mutex_unlock(&aesocket_mutex);
/* already cancelled */
}
+#else
+ /* TODO: implement cancel in epoll version */
+ assert(0);
+#endif
return(TRITON_SUCCESS);
}
@@ -233,11 +314,13 @@ triton_ret_t triton_aesocket_init(
triton_ret_t tret;
int ret;
+#ifdef __AESOP_LIBEV
event_loop_thread = pthread_self();
ae_ops_init(&posted_oplist);
ae_ops_init(&cancelled_oplist);
ae_ops_init(&inflight_oplist);
+#endif
tret = AE_OPCACHE_INIT(struct aesocket_op,
op,
@@ -247,6 +330,22 @@ triton_ret_t triton_aesocket_init(
{
return tret;
}
+#ifdef __AESOP_EPOLL
+ epfd = epoll_create(32);
+ if(epfd < 0)
+ {
+ ae_opcache_destroy(aesocket_opcache);
+ return(TRITON_ERR_EPOLL);
+ }
+ epoll_thread_running = 1;
+ ret = pthread_create(&epoll_thread, NULL, thread_fn, NULL);
+ if(ret < 0)
+ {
+ ae_opcache_destroy(aesocket_opcache);
+ close(epfd);
+ return(TRITON_ERR_EPOLL);
+ }
+#endif
return ae_resource_register(&triton_aesocket_resource,
&triton_aesocket_resource_id);
@@ -255,6 +354,11 @@ triton_ret_t triton_aesocket_init(
void triton_aesocket_finalize(
void)
{
+#ifdef __AESOP_EPOLL
+ epoll_thread_running = 0;
+ pthread_join(epoll_thread, NULL);
+ close(epfd);
+#endif
ae_resource_unregister(triton_aesocket_resource_id);
ae_opcache_destroy(aesocket_opcache);
}
hooks/post-receive
--
Triton Repository
1
0