2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-07 10:05:50 +00:00
Files
bind/lib/isc/win32/resource.c

73 lines
2.0 KiB
C
Raw Normal View History

2001-07-06 05:37:10 +00:00
/*
2007-06-19 23:47:24 +00:00
* Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
2001-07-06 05:37:10 +00:00
* Copyright (C) 2000, 2001 Internet Software Consortium.
*
2007-06-18 23:47:57 +00:00
* Permission to use, copy, modify, and/or distribute this software for any
2001-07-06 05:37:10 +00:00
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
2004-03-05 05:14:21 +00:00
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
* OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
2001-07-06 05:37:10 +00:00
*/
/* $Id: resource.c,v 1.9 2008/07/11 23:05:46 jinmei Exp $ */
2001-07-06 05:37:10 +00:00
#include <config.h>
#include <stdio.h>
2001-07-06 05:37:10 +00:00
#include <isc/platform.h>
#include <isc/resource.h>
#include <isc/result.h>
#include <isc/util.h>
#include "errno2result.h"
/*
* Windows limits the maximum number of open files to 2048
*/
#define WIN32_MAX_OPEN_FILES 2048
2001-07-06 05:37:10 +00:00
isc_result_t
isc_resource_setlimit(isc_resource_t resource, isc_resourcevalue_t value) {
isc_resourcevalue_t rlim_value;
int wresult;
if (resource != isc_resource_openfiles)
2001-10-26 02:29:43 +00:00
return (ISC_R_NOTIMPLEMENTED);
2001-07-06 05:37:10 +00:00
if (value == ISC_RESOURCE_UNLIMITED)
rlim_value = WIN32_MAX_OPEN_FILES;
else
rlim_value = min(value, WIN32_MAX_OPEN_FILES);
wresult = _setmaxstdio((int) rlim_value);
if (wresult > 0)
return (ISC_R_SUCCESS);
else
return (isc__errno2result(errno));
2001-07-06 05:37:10 +00:00
}
isc_result_t
isc_resource_getlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
if (resource != isc_resource_openfiles)
2001-10-26 02:29:43 +00:00
return (ISC_R_NOTIMPLEMENTED);
*value = WIN32_MAX_OPEN_FILES;
return (ISC_R_SUCCESS);
2001-07-06 05:37:10 +00:00
}
isc_result_t
isc_resource_getcurlimit(isc_resource_t resource, isc_resourcevalue_t *value) {
return (isc_resource_getlimit(resource, value));
}