"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.16.7/lib/isc/win32/resource.c" (4 Sep 2020, 1511 Bytes) of package /linux/misc/dns/bind9/9.16.7/bind-9.16.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "resource.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #include <stdio.h>
   13 
   14 #include <isc/platform.h>
   15 #include <isc/resource.h>
   16 #include <isc/result.h>
   17 #include <isc/util.h>
   18 
   19 #include "errno2result.h"
   20 
   21 /*
   22  * Windows limits the maximum number of open files to 2048
   23  */
   24 
   25 #define WIN32_MAX_OPEN_FILES 2048
   26 
   27 isc_result_t
   28 isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
   29     isc_resourcevalue_t rlim_value;
   30     int wresult;
   31 
   32     if (resource != isc_resource_openfiles) {
   33         return (ISC_R_NOTIMPLEMENTED);
   34     }
   35 
   36     if (value == ISC_RESOURCE_UNLIMITED) {
   37         rlim_value = WIN32_MAX_OPEN_FILES;
   38     } else {
   39         rlim_value = min(value, WIN32_MAX_OPEN_FILES);
   40     }
   41 
   42     wresult = _setmaxstdio((int)rlim_value);
   43 
   44     if (wresult > 0) {
   45         return (ISC_R_SUCCESS);
   46     } else {
   47         return (isc__errno2result(errno));
   48     }
   49 }
   50 
   51 isc_result_t
   52 isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
   53     if (resource != isc_resource_openfiles) {
   54         return (ISC_R_NOTIMPLEMENTED);
   55     }
   56 
   57     *value = WIN32_MAX_OPEN_FILES;
   58     return (ISC_R_SUCCESS);
   59 }
   60 
   61 isc_result_t
   62 isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
   63     return (isc_resource_getlimit(resource, value));
   64 }