svn commit: samba r3017 - in branches/SAMBA_4_0/source: include lib
libcli/raw ntvfs/cifs
tridge at samba.org
tridge at samba.org
Sun Oct 17 11:37:22 GMT 2004
Author: tridge
Date: 2004-10-17 11:37:22 +0000 (Sun, 17 Oct 2004)
New Revision: 3017
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source&rev=3017&nolog=1
Log:
nicer memory handling for event_context_merge()
Modified:
branches/SAMBA_4_0/source/include/events.h
branches/SAMBA_4_0/source/lib/events.c
branches/SAMBA_4_0/source/libcli/raw/clitransport.c
branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c
Changeset:
Modified: branches/SAMBA_4_0/source/include/events.h
===================================================================
--- branches/SAMBA_4_0/source/include/events.h 2004-10-17 10:04:49 UTC (rev 3016)
+++ branches/SAMBA_4_0/source/include/events.h 2004-10-17 11:37:22 UTC (rev 3017)
@@ -68,7 +68,8 @@
int code;
} exit;
- int ref_count;
+ /* we hang the events off here, to make merging easy */
+ void *events;
};
Modified: branches/SAMBA_4_0/source/lib/events.c
===================================================================
--- branches/SAMBA_4_0/source/lib/events.c 2004-10-17 10:04:49 UTC (rev 3016)
+++ branches/SAMBA_4_0/source/lib/events.c 2004-10-17 11:37:22 UTC (rev 3017)
@@ -81,7 +81,7 @@
/* start off with no events */
ZERO_STRUCTP(ev);
- ev->ref_count = 1;
+ ev->events = talloc(ev, 0);
return ev;
}
@@ -91,11 +91,6 @@
*/
void event_context_destroy(struct event_context *ev)
{
- ev->ref_count--;
- if (ev->ref_count != 0) {
- return;
- }
-
talloc_free(ev);
}
@@ -121,18 +116,18 @@
this is used by modules that need to call on the events of a lower module
*/
-struct event_context * event_context_merge(struct event_context *ev, struct event_context *ev2)
+struct event_context *event_context_merge(struct event_context *ev, struct event_context *ev2)
{
DLIST_CONCATENATE(ev->fd_events, ev2->fd_events, struct fd_event *);
DLIST_CONCATENATE(ev->timed_events, ev2->timed_events, struct timed_event *);
DLIST_CONCATENATE(ev->loop_events, ev2->loop_events, struct loop_event *);
- ev->ref_count++;
-
ev2->fd_events = NULL;
ev2->timed_events = NULL;
ev2->loop_events = NULL;
+ talloc_steal(ev->events, ev2->events);
+
event_context_destroy(ev2);
calc_maxfd(ev);
@@ -147,7 +142,7 @@
*/
struct fd_event *event_add_fd(struct event_context *ev, struct fd_event *e)
{
- e = talloc_memdup(ev, e, sizeof(*e));
+ e = talloc_memdup(ev->events, e, sizeof(*e));
if (!e) return NULL;
DLIST_ADD(ev->fd_events, e);
e->ref_count = 1;
@@ -217,7 +212,7 @@
*/
struct timed_event *event_add_timed(struct event_context *ev, struct timed_event *e)
{
- e = talloc_memdup(ev, e, sizeof(*e));
+ e = talloc_memdup(ev->events, e, sizeof(*e));
if (!e) return NULL;
e->ref_count = 1;
DLIST_ADD(ev->timed_events, e);
@@ -246,7 +241,7 @@
*/
struct loop_event *event_add_loop(struct event_context *ev, struct loop_event *e)
{
- e = talloc_memdup(ev, e, sizeof(*e));
+ e = talloc_memdup(ev->events, e, sizeof(*e));
if (!e) return NULL;
e->ref_count = 1;
DLIST_ADD(ev->loop_events, e);
@@ -302,7 +297,7 @@
struct loop_event *next = le->next;
if (le->ref_count == 0) {
DLIST_REMOVE(ev->loop_events, le);
- talloc_unlink(ev, le);
+ talloc_unlink(ev->events, le);
} else {
le->ref_count++;
le->handler(ev, le, t);
@@ -323,7 +318,7 @@
if (ev->maxfd == fe->fd) {
ev->maxfd = EVENT_INVALID_MAXFD;
}
- talloc_unlink(ev, fe);
+ talloc_unlink(ev->events, fe);
} else {
if (fe->flags & EVENT_FD_READ) {
FD_SET(fe->fd, &r_fds);
@@ -404,7 +399,7 @@
struct timed_event *next = te->next;
if (te->ref_count == 0) {
DLIST_REMOVE(ev->timed_events, te);
- talloc_unlink(ev, te);
+ talloc_unlink(ev->events, te);
} else if (te->next_event <= t) {
te->ref_count++;
te->handler(ev, te, t);
Modified: branches/SAMBA_4_0/source/libcli/raw/clitransport.c
===================================================================
--- branches/SAMBA_4_0/source/libcli/raw/clitransport.c 2004-10-17 10:04:49 UTC (rev 3016)
+++ branches/SAMBA_4_0/source/libcli/raw/clitransport.c 2004-10-17 11:37:22 UTC (rev 3017)
@@ -51,7 +51,6 @@
smbcli_transport_dead(transport);
event_remove_fd(transport->event.ctx, transport->event.fde);
event_remove_timed(transport->event.ctx, transport->event.te);
- event_context_destroy(transport->event.ctx);
return 0;
}
Modified: branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c 2004-10-17 10:04:49 UTC (rev 3016)
+++ branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c 2004-10-17 11:37:22 UTC (rev 3017)
@@ -138,7 +138,6 @@
private->transport = private->tree->session->transport;
private->tree->session->pid = SVAL(req->in.hdr, HDR_PID);
private->tcon = req->tcon;
- /*private->ops = ntvfs_backend_byname("cifs", NTVFS_DISK);*/
tcon->fs_type = talloc_strdup(tcon, "NTFS");
tcon->dev_type = talloc_strdup(tcon, "A:");
@@ -151,7 +150,8 @@
private->transport->event.fde->private = private;
private->transport->event.ctx = event_context_merge(tcon->smb_conn->connection->event.ctx,
- private->transport->event.ctx);
+ private->transport->event.ctx);
+ talloc_reference(private, private->transport->event.ctx);
return NT_STATUS_OK;
}
More information about the samba-cvs
mailing list