From 720c01b58621857f8cd154deb6c1df84ef581cee Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sat, 15 Feb 2014 17:51:38 -0500 Subject: [PATCH] Set up per-session NNTP state structure, alloc and free --- citadel/modules/nntp/serv_nntp.c | 11 +++++++--- citadel/modules/nntp/serv_nntp.h | 37 ++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/citadel/modules/nntp/serv_nntp.c b/citadel/modules/nntp/serv_nntp.c index 6a75c622a..1978c269a 100644 --- a/citadel/modules/nntp/serv_nntp.c +++ b/citadel/modules/nntp/serv_nntp.c @@ -185,9 +185,9 @@ void nntp_greeting(void) strcpy(CC->cs_clientname, "NNTP session"); CC->cs_flags |= CS_STEALTH; - /* CC->session_specific_data = malloc(sizeof(citnntp)); - memset(NNTP, 0, sizeof(citnntp)); - */ + CC->session_specific_data = malloc(sizeof(citnntp)); + citnntp *nntpstate = (citnntp *) CC->session_specific_data; + memset(nntpstate, 0, sizeof(citnntp)); if (CC->nologin==1) { cprintf("451 Too many connections are already open; please try again later.\r\n"); @@ -897,6 +897,11 @@ void nntp_cleanup_function(void) if (CC->h_command_function != nntp_command_loop) return; syslog(LOG_DEBUG, "Performing NNTP cleanup hook\n"); + citnntp *nntpstate = (citnntp *) CC->session_specific_data; + if (nntpstate != NULL) { + free(nntpstate); + nntpstate = NULL; + } } const char *CitadelServiceNNTP="NNTP"; diff --git a/citadel/modules/nntp/serv_nntp.h b/citadel/modules/nntp/serv_nntp.h index 31295ce16..e7aed6e1d 100644 --- a/citadel/modules/nntp/serv_nntp.h +++ b/citadel/modules/nntp/serv_nntp.h @@ -1,16 +1,16 @@ -/* - * Header file for NNTP server module - * - * Copyright (c) 2014 by the citadel.org team - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// +// Header file for NNTP server module +// +// Copyright (c) 2014 by the citadel.org team +// +// This program is open source software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// // data returned by a message list fetch @@ -27,14 +27,19 @@ struct nntp_list_data { }; -/* - * data passed between nntp_listgroup() and nntp_listgroup_backend() - */ +// +// data passed between nntp_listgroup() and nntp_listgroup_backend() +// struct listgroup_range { long lo; long hi; }; + +typedef struct _citnntp { // Information about the current session + int foo; // dummy thingo +} citnntp; + int wildmat(const char *text, const char *p); -- 2.30.2