The pre-init stage honors max-sockets as well.
[yazproxy-moved-to-github.git] / src / yaz-proxy-config.cpp
index 0a71115..7fe6204 100644 (file)
@@ -1,5 +1,5 @@
-/* $Id: yaz-proxy-config.cpp,v 1.34 2006-07-06 11:50:26 adam Exp $
-   Copyright (c) 1998-2006, Index Data.
+/* $Id: yaz-proxy-config.cpp,v 1.37 2007-05-08 12:05:09 adam Exp $
+   Copyright (c) 1998-2007, Index Data.
 
 This file is part of the yazproxy.
 
@@ -23,6 +23,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 #include <yaz/log.h>
 #include "proxyp.h"
+#include <yaz/oid_db.h>
 
 class Yaz_ProxyConfigP {
     friend class Yaz_ProxyConfig;
@@ -41,6 +42,7 @@ class Yaz_ProxyConfigP {
                             int *limit_bw, int *limit_pdu, int *limit_req,
                             int *limit_search,
                             int *target_idletime, int *client_idletime,
+                            int *max_sockets,
                             int *keepalive_limit_bw, int *keepalive_limit_pdu,
                             int *pre_init, const char **cql2rpn,
                             const char **negotiation_charset,
@@ -230,6 +232,7 @@ void Yaz_ProxyConfigP::return_target_info(xmlNodePtr ptr,
                                           int *limit_search,
                                           int *target_idletime,
                                           int *client_idletime,
+                                          int *max_sockets,
                                           int *keepalive_limit_bw,
                                           int *keepalive_limit_pdu,
                                           int *pre_init,
@@ -296,6 +299,15 @@ void Yaz_ProxyConfigP::return_target_info(xmlNodePtr ptr,
             }
         }
         if (ptr->type == XML_ELEMENT_NODE
+            && !strcmp((const char *) ptr->name, "max-sockets"))
+        {
+            const char *t = get_text(ptr);
+            if (t && max_sockets)
+            {
+                *max_sockets = atoi(t);
+            }
+        }
+        if (ptr->type == XML_ELEMENT_NODE
             && !strcmp((const char *) ptr->name, "cql2rpn"))
         {
             const char *t = get_text(ptr);
@@ -822,8 +834,10 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                 }
                 else if (syntax)
                 {
-                    int match_oid[OID_SIZE];
-                    oid_name_to_oid(CLASS_RECSYN, match_type, match_oid);
+                    Odr_oid *match_oid 
+                        = yaz_string_to_oid_odr(yaz_oid_std(),
+                                                CLASS_RECSYN, match_type,
+                                                odr);
                     if (oid_oidcmp(match_oid, syntax) == 0)
                         match = 1;
                 }
@@ -877,8 +891,8 @@ int Yaz_ProxyConfig::check_syntax(ODR odr, const char *name,
                         return 25;
                     if (syntax)
                     {
-                        char dotoid_str[100];
-                        oid_to_dotstring(syntax, dotoid_str);
+                        char dotoid_str[OID_STR_MAX];
+                        oid_oid_to_dotstring(syntax, dotoid_str);
                         *addinfo = odr_strdup(odr, dotoid_str);
                     }
                     return atoi(match_error);
@@ -979,6 +993,7 @@ int Yaz_ProxyConfig::get_target_no(int no,
                                    int *limit_search,
                                    int *target_idletime,
                                    int *client_idletime,
+                                   int *max_sockets,
                                    int *max_clients,
                                    int *keepalive_limit_bw,
                                    int *keepalive_limit_pdu,
@@ -1015,6 +1030,7 @@ int Yaz_ProxyConfig::get_target_no(int no,
                     limit_bw, limit_pdu, limit_req,
                     limit_search,
                     target_idletime, client_idletime,
+                    max_sockets,
                     keepalive_limit_bw, keepalive_limit_pdu,
                     pre_init, cql2rpn,
                     negotiation_charset, negotiation_lang, target_charset,
@@ -1294,6 +1310,7 @@ void Yaz_ProxyConfig::get_target_info(const char *name,
                                       int *limit_search,
                                       int *target_idletime,
                                       int *client_idletime,
+                                      int *max_sockets,
                                       int *max_clients,
                                       int *keepalive_limit_bw,
                                       int *keepalive_limit_pdu,
@@ -1338,6 +1355,7 @@ void Yaz_ProxyConfig::get_target_info(const char *name,
         m_cp->return_target_info(ptr, url, limit_bw, limit_pdu, limit_req,
                                  limit_search,
                                  target_idletime, client_idletime,
+                                 max_sockets,
                                  keepalive_limit_bw, keepalive_limit_pdu,
                                  pre_init, cql2rpn,
                                  negotiation_charset, negotiation_lang,