source: trunk/libtransmission/fdlimit.h @ 4311

Last change on this file since 4311 was 4311, checked in by charles, 15 years ago

(gtk) fix startup port issue by hitting it with a damn big hammer

  • Property svn:keywords set to Date Rev Author Id
File size: 3.5 KB
Line 
1/******************************************************************************
2 * $Id: fdlimit.h 4311 2007-12-24 07:02:40Z charles $
3 *
4 * Copyright (c) 2005-2006 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#include "net.h"
26
27/***********************************************************************
28 * tr_fdInit
29 ***********************************************************************
30 * Detect the maximum number of open files and initializes things.
31 **********************************************************************/
32void tr_fdInit( int globalPeerLimit );
33
34void tr_fdClose( void );
35
36/**
37 * Returns an fd to the specified filename.
38 *
39 * A small repository of open files is kept to avoid the overhead of continually
40 * opening and closing the same files when writing piece data during download.
41 * It's also used to ensure that only one client uses the file at a time.
42 * Clients must check out a file to use it, then return it, like a library, when done.
43 *
44 * if write is nonzero and dirname(filename) doesn't exist, dirname is created.
45 * if write is nonzero and filename doesn't exist, filename is created.
46 * returns the fd if successful; otherwise, one of TR_ERROR_IO_*
47 *
48 * @see tr_fdFileReturn
49 * @see tr_fdFileClose
50 */
51int tr_fdFileCheckout( const char * filename, int write );
52
53/**
54 * Returns an fd from tr_fdFileCheckout() so that other clients may borrow it.
55 *
56 * @see tr_fdFileCheckout
57 * @see tr_fdFileClose
58 */
59void tr_fdFileReturn( int file );
60
61/**
62 * Closes a file that's being held by our file repository.
63 *
64 * If the file isn't checked out, it's closed immediately.
65 * If the file is currently checked out, it will be closed upon its return.
66 *
67 * @see tr_fdFileCheckout
68 * @see tr_fdFileReturn
69 */
70void tr_fdFileClose( const char * filename );
71
72
73
74/***********************************************************************
75 * Sockets
76 **********************************************************************/
77int  tr_fdSocketCreate( int type, int priority );
78int  tr_fdSocketAccept( int b, struct in_addr * addr, tr_port_t * port );
79void tr_fdSocketClose( int s );
80
81/***********************************************************************
82 * tr_fdClose
83 ***********************************************************************
84 * Frees resources allocated by tr_fdInit.
85 **********************************************************************/
86void tr_fdClose( void );
87
88
89void tr_fdSetPeerLimit( uint16_t n );
90
91uint16_t tr_fdGetPeerLimit( void );
92
Note: See TracBrowser for help on using the repository browser.