Edit

IABSD.fr/ports/net/libproxy/patches/patch-libproxy_url_cpp

Branch :

  • Show log

    Commit

  • Author : naddy
    Date : 2022-03-11 19:45:43
    Hash : 3f5796b9
    Message : drop RCS Ids

  • net/libproxy/patches/patch-libproxy_url_cpp
  • https://code.google.com/p/libproxy/issues/detail?id=196&thanks=196&ts=1370457244
    
    Index: libproxy/url.cpp
    --- libproxy/url.cpp.orig
    +++ libproxy/url.cpp
    @@ -46,6 +46,10 @@
     using namespace libproxy;
     using namespace std;
     
    +#ifndef WIN32
    +static pthread_mutex_t servmtx = PTHREAD_MUTEX_INITIALIZER;
    +#endif
    +
     // This mime type should be reported by the web server
     #define PAC_MIME_TYPE "application/x-ns-proxy-autoconfig"
     // Fall back to checking for this mime type, which servers often report wrong
    @@ -59,14 +63,22 @@ using namespace std;
     static inline int get_default_port(string scheme) {
     	struct servent *serv;
     	size_t plus = scheme.find('+');
    +	int ret = 0;
     
     	if (plus != string::npos)
     		scheme = scheme.substr(plus + 1);
     
    -	if ((serv = getservbyname(scheme.c_str(), NULL)))
    -		return ntohs(serv->s_port);
    +#ifndef WIN32
    +	pthread_mutex_lock(&servmtx);
    +#endif
    +	serv = getservbyname(scheme.c_str(), NULL);
    +	if (serv)
    +		ret = ntohs(serv->s_port);
    +#ifndef WIN32
    +	pthread_mutex_unlock(&servmtx);
    +#endif
     
    -	return 0;
    +	return ret;
     }
     
     template <class T>