Ticket #27325: pound.diff

File pound.diff, 10.2 KB (added by ryandesign (Ryan Carsten Schmidt), 13 years ago)

proposed patch

  • files/pound-2.5-openssl.patch

     
     1diff -up Pound-2.5/config.c.openssl Pound-2.5/config.c
     2--- Pound-2.5/config.c.openssl  2010-02-10 12:23:09.000000000 +0100
     3+++ Pound-2.5/config.c  2010-02-10 12:23:07.000000000 +0100
     4@@ -431,14 +431,22 @@ t_hash(const TABNODE *e)
     5         res = (res ^ *k++) * 16777619;
     6     return res;
     7 }
     8+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     9+static IMPLEMENT_LHASH_HASH_FN(t, TABNODE)
     10+#else
     11 static IMPLEMENT_LHASH_HASH_FN(t_hash, const TABNODE *)
     12+#endif
     13 
     14 static int
     15 t_cmp(const TABNODE *d1, const TABNODE *d2)
     16 {
     17     return strcmp(d1->key, d2->key);
     18 }
     19+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     20+static IMPLEMENT_LHASH_COMP_FN(t, TABNODE)
     21+#else
     22 static IMPLEMENT_LHASH_COMP_FN(t_cmp, const TABNODE *)
     23+#endif
     24 
     25 /*
     26  * parse a service
     27@@ -460,7 +468,11 @@ parse_service(const char *svc_name)
     28     pthread_mutex_init(&res->mut, NULL);
     29     if(svc_name)
     30         strncpy(res->name, svc_name, KEY_SIZE);
     31+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     32+    if((res->sessions = LHM_lh_new(TABNODE, t)) == NULL)
     33+#else
     34     if((res->sessions = lh_new(LHASH_HASH_FN(t_hash), LHASH_COMP_FN(t_cmp))) == NULL)
     35+#endif
     36         conf_err("lh_new failed - aborted");
     37     ign_case = ignore_case;
     38     while(conf_fgets(lin, MAXBUF)) {
     39diff -up Pound-2.5/pound.h.openssl Pound-2.5/pound.h
     40--- Pound-2.5/pound.h.openssl   2010-02-02 12:49:02.000000000 +0100
     41+++ Pound-2.5/pound.h   2010-02-10 12:15:18.000000000 +0100
     42@@ -322,6 +322,10 @@ typedef struct _tn {
     43 /* maximal session key size */
     44 #define KEY_SIZE    127
     45 
     46+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     47+DECLARE_LHASH_OF(TABNODE);
     48+#endif
     49+
     50 /* service definition */
     51 typedef struct _service {
     52     char                name[KEY_SIZE + 1]; /* symbolic name */
     53@@ -337,7 +341,11 @@ typedef struct _service {
     54     int                 sess_ttl;   /* session time-to-live */
     55     regex_t             sess_start; /* pattern to identify the session data */
     56     regex_t             sess_pat;   /* pattern to match the session data */
     57+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     58+    LHASH_OF(TABNODE)   *sessions;  /* currently active sessions */
     59+#else
     60     LHASH               *sessions;  /* currently active sessions */
     61+#endif
     62     int                 dynscale;   /* true if the back-ends should be dynamically rescaled */
     63     int                 disabled;   /* true if the service is disabled */
     64     struct _service     *next;
     65diff -up Pound-2.5/svc.c.openssl Pound-2.5/svc.c
     66--- Pound-2.5/svc.c.openssl     2010-02-02 12:49:02.000000000 +0100
     67+++ Pound-2.5/svc.c     2010-02-10 12:13:29.000000000 +0100
     68@@ -27,12 +27,17 @@
     69 
     70 #include    "pound.h"
     71 
     72+#ifndef LHASH_OF
     73+#define LHASH_OF(x) LHASH
     74+#define CHECKED_LHASH_OF(type, h) h
     75+#endif
     76+
     77 /*
     78  * Add a new key/content pair to a hash table
     79  * the table should be already locked
     80  */
     81 static void
     82-t_add(LHASH *const tab, const char *key, const void *content, const size_t cont_len)
     83+t_add(LHASH_OF(TABNODE) *const tab, const char *key, const void *content, const size_t cont_len)
     84 {
     85     TABNODE *t, *old;
     86 
     87@@ -53,7 +58,11 @@ t_add(LHASH *const tab, const char *key,
     88     }
     89     memcpy(t->content, content, cont_len);
     90     t->last_acc = time(NULL);
     91+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     92+    if((old = LHM_lh_insert(TABNODE, tab, t)) != NULL) {
     93+#else
     94     if((old = (TABNODE *)lh_insert(tab, t)) != NULL) {
     95+#endif
     96         free(old->key);
     97         free(old->content);
     98         free(old);
     99@@ -68,12 +77,16 @@ t_add(LHASH *const tab, const char *key,
     100  * side-effect: update the time of last access
     101  */
     102 static void *
     103-t_find(LHASH *const tab, char *const key)
     104+t_find(LHASH_OF(TABNODE) *const tab, char *const key)
     105 {
     106     TABNODE t, *res;
     107 
     108     t.key = key;
     109+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     110+    if((res = LHM_lh_retrieve(TABNODE, tab, &t)) != NULL) {
     111+#else
     112     if((res = (TABNODE *)lh_retrieve(tab, &t)) != NULL) {
     113+#endif
     114         res->last_acc = time(NULL);
     115         return res->content;
     116     }
     117@@ -84,12 +97,16 @@ t_find(LHASH *const tab, char *const key
     118  * Delete a key
     119  */
     120 static void
     121-t_remove(LHASH *const tab, char *const key)
     122+t_remove(LHASH_OF(TABNODE) *const tab, char *const key)
     123 {
     124     TABNODE t, *res;
     125 
     126     t.key = key;
     127+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     128+    if((res = LHM_lh_delete(TABNODE, tab, &t)) != NULL) {
     129+#else
     130     if((res = (TABNODE *)lh_delete(tab, &t)) != NULL) {
     131+#endif
     132         free(res->key);
     133         free(res->content);
     134         free(res);
     135@@ -98,59 +115,75 @@ t_remove(LHASH *const tab, char *const k
     136 }
     137 
     138 typedef struct  {
     139-    LHASH   *tab;
     140+    LHASH_OF(TABNODE) *tab;
     141     time_t  lim;
     142     void    *content;
     143     int     cont_len;
     144 }   ALL_ARG;
     145 
     146 static void
     147-t_old(TABNODE *t, void *arg)
     148+t_old_doall_arg(TABNODE *t, ALL_ARG *a)
     149 {
     150-    ALL_ARG *a;
     151-
     152-    a = (ALL_ARG *)arg;
     153     if(t->last_acc < a->lim)
     154+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     155+        LHM_lh_delete(TABNODE, a->tab, t);
     156+#else
     157         lh_delete(a->tab, t);
     158+#endif
     159     return;
     160 }
     161-IMPLEMENT_LHASH_DOALL_ARG_FN(t_old, TABNODE *, void *)
     162+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     163+IMPLEMENT_LHASH_DOALL_ARG_FN(t_old, TABNODE, ALL_ARG)
     164+#else
     165+#define t_old t_old_doall_arg
     166+IMPLEMENT_LHASH_DOALL_ARG_FN(t_old, TABNODE *, ALL_ARG *)
     167+#endif
     168 
     169 /*
     170  * Expire all old nodes
     171  */
     172 static void
     173-t_expire(LHASH *const tab, const time_t lim)
     174+t_expire(LHASH_OF(TABNODE) *const tab, const time_t lim)
     175 {
     176     ALL_ARG a;
     177     int down_load;
     178 
     179     a.tab = tab;
     180     a.lim = lim;
     181-    down_load = tab->down_load;
     182-    tab->down_load = 0;
     183+    down_load = CHECKED_LHASH_OF(TABNODE, tab)->down_load;
     184+    CHECKED_LHASH_OF(TABNODE, tab)->down_load = 0;
     185+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     186+    LHM_lh_doall_arg(TABNODE, tab, LHASH_DOALL_ARG_FN(t_old), ALL_ARG, &a);
     187+#else
     188     lh_doall_arg(tab, LHASH_DOALL_ARG_FN(t_old), &a);
     189-    tab->down_load = down_load;
     190+#endif
     191+    CHECKED_LHASH_OF(TABNODE, tab)->down_load = down_load;
     192     return;
     193 }
     194 
     195 static void
     196-t_cont(TABNODE *t, void *arg)
     197+t_cont_doall_arg(TABNODE *t, ALL_ARG *a)
     198 {
     199-    ALL_ARG *a;
     200-
     201-    a = (ALL_ARG *)arg;
     202     if(memcmp(t->content, a->content, a->cont_len) == 0)
     203+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     204+        LHM_lh_delete(TABNODE, a->tab, t);
     205+#else
     206         lh_delete(a->tab, t);
     207+#endif
     208     return;
     209 }
     210-IMPLEMENT_LHASH_DOALL_ARG_FN(t_cont, TABNODE *, void *)
     211+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     212+IMPLEMENT_LHASH_DOALL_ARG_FN(t_cont, TABNODE, ALL_ARG)
     213+#else
     214+#define t_cont t_cont_doall_arg
     215+IMPLEMENT_LHASH_DOALL_ARG_FN(t_cont, TABNODE *, ALL_ARG *)
     216+#endif
     217 
     218 /*
     219  * Remove all nodes with the given content
     220  */
     221 static void
     222-t_clean(LHASH *const tab, void *const content, const size_t cont_len)
     223+t_clean(LHASH_OF(TABNODE) *const tab, void *const content, const size_t cont_len)
     224 {
     225     ALL_ARG a;
     226     int down_load;
     227@@ -158,10 +191,14 @@ t_clean(LHASH *const tab, void *const co
     228     a.tab = tab;
     229     a.content = content;
     230     a.cont_len = cont_len;
     231-    down_load = tab->down_load;
     232-    tab->down_load = 0;
     233+    down_load = CHECKED_LHASH_OF(TABNODE, tab)->down_load;
     234+    CHECKED_LHASH_OF(TABNODE, tab)->down_load = 0;
     235+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     236+    LHM_lh_doall_arg(TABNODE, tab, LHASH_DOALL_ARG_FN(t_cont), ALL_ARG, &a);
     237+#else
     238     lh_doall_arg(tab, LHASH_DOALL_ARG_FN(t_cont), &a);
     239-    tab->down_load = down_load;
     240+#endif
     241+    CHECKED_LHASH_OF(TABNODE, tab)->down_load = down_load;
     242     return;
     243 }
     244 
     245@@ -1410,13 +1447,11 @@ typedef struct  {
     246 }   DUMP_ARG;
     247 
     248 static void
     249-t_dump(TABNODE *t, void *arg)
     250+t_dump_doall_arg(TABNODE *t, DUMP_ARG *a)
     251 {
     252-    DUMP_ARG    *a;
     253     BACKEND     *be, *bep;
     254     int         n_be, sz;
     255 
     256-    a = (DUMP_ARG *)arg;
     257     memcpy(&bep, t->content, sizeof(bep));
     258     for(n_be = 0, be = a->backends; be; be = be->next, n_be++)
     259         if(be == bep)
     260@@ -1432,19 +1467,28 @@ t_dump(TABNODE *t, void *arg)
     261     return;
     262 }
     263 
     264-IMPLEMENT_LHASH_DOALL_ARG_FN(t_dump, TABNODE *, void *)
     265+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     266+IMPLEMENT_LHASH_DOALL_ARG_FN(t_dump, TABNODE, DUMP_ARG)
     267+#else
     268+#define t_dump t_dump_doall_arg
     269+IMPLEMENT_LHASH_DOALL_ARG_FN(t_dump, TABNODE *, DUMP_ARG *)
     270+#endif
     271 
     272 /*
     273  * write sessions to the control socket
     274  */
     275 static void
     276-dump_sess(const int control_sock, LHASH *const sess, BACKEND *const backends)
     277+dump_sess(const int control_sock, LHASH_OF(TABNODE) *const sess, BACKEND *const backends)
     278 {
     279     DUMP_ARG a;
     280 
     281     a.control_sock = control_sock;
     282     a.backends = backends;
     283+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
     284+    LHM_lh_doall_arg(TABNODE, sess, LHASH_DOALL_ARG_FN(t_dump), DUMP_ARG, &a);
     285+#else
     286     lh_doall_arg(sess, LHASH_DOALL_ARG_FN(t_dump), &a);
     287+#endif
     288     return;
     289 }
     290 
  • Portfile

     
    33PortSystem        1.0
    44
    55name              pound
    6 version           2.4.3
    7 revision        1
     6version           2.5
    87categories        www
    98platforms         darwin
    109maintainers       gmail.com:rcavanaugh
     
    2019distname          Pound-${version}
    2120extract.suffix    .tgz
    2221master_sites      ${homepage}
    23 checksums         md5 2de4c2ac1023b420b74a1bc08fb93b8a \
    24                   sha1 1d86e134bf307c9e2f10f647a73925339ba96575 \
    25                   rmd160 a59c5fda7ce12513a894c4cbe59708f2fb73caa3
    2622
     23checksums         sha1    0bc8c45b9afb64fb8810b44213345c2a67ce8a8c \
     24                  rmd160  6f8d55eff11b25b0ac0dab66aac90af5380e2753
     25
    2726# TODO use tcmalloc and/or hoard
    2827depends_lib       port:openssl port:pcre
    29 configure.args    --mandir=\\\$\\{prefix\\}/share/man \
    30                   --infodir=\\\$\\{prefix\\}/share/info \
    31                   --with-ssl=${prefix}/include/openssl
    3228
     29patchfiles        pound-2.5-openssl.patch
     30patch.pre_args    -p1
     31
     32configure.args    --with-ssl=${prefix}
     33
    3334set pound_config_name   pound.cfg
    3435set pound_config        ${prefix}/etc/${pound_config_name}
    3536set pound_pidfile_name  pound.pid