source: trunk/libtransmission/fdlimit.h @ 12545

Last change on this file since 12545 was 12514, checked in by jordan, 10 years ago

(trunk libt) #4315 "Transmission 2.31 crashes (segfaults) immediately after launch" -- remove the "max-open-files" code.

max-open-files might have been a nice configuration option once, but (1) we've never advertised it in the gui apps, and (2) the crazy cases are causing more trouble than this feature is worth. It's more complicated now after #4164 -- see #4294, #4311, and this ticket.

  • Property svn:keywords set to Date Rev Author Id
File size: 4.0 KB
Line 
1/*
2 * This file Copyright (C) Mnemosyne LLC
3 *
4 * This file is licensed by the GPL version 2. Works owned by the
5 * Transmission project are granted a special exemption to clause 2(b)
6 * so that the bulk of its code can remain under the MIT license.
7 * This exemption does not extend to derived works not owned by
8 * the Transmission project.
9 *
10 * $Id: fdlimit.h 12514 2011-06-24 22:39:20Z jordan $
11 */
12
13#ifndef __TRANSMISSION__
14 #error only libtransmission should #include this header.
15#endif
16
17#include "transmission.h"
18#include "net.h"
19
20/**
21 * @addtogroup file_io File IO
22 * @{
23 */
24
25/***
26****
27***/
28
29void tr_set_file_for_single_pass( int fd );
30
31int tr_open_file_for_scanning( const char * filename );
32
33int tr_open_file_for_writing( const char * filename );
34
35void tr_close_file( int fd );
36
37int tr_fsync(int fd);
38
39ssize_t tr_pread(int fd, void *buf, size_t count, off_t offset);
40ssize_t tr_pwrite(int fd, const void *buf, size_t count, off_t offset);
41int tr_prefetch(int fd, off_t offset, size_t count);
42
43
44/**
45 * Returns an fd to the specified filename.
46 *
47 * A small pool of open files is kept to avoid the overhead of
48 * continually opening and closing the same files when downloading
49 * piece data.
50 *
51 * - if do_write is true, subfolders in torrentFile are created if necessary.
52 * - if do_write is true, the target file is created if necessary.
53 *
54 * @param existing_dir An ancestor of filename which must already exist and
55 *                     won't be created by tr_fdFileCheckout(). This prevents
56 *                     directories from being created in error, such as a mount
57 *                     point for an external drive when the drive is unplugged.
58 *
59 * on success, a file descriptor >= 0 is returned.
60 * on failure, a -1 is returned and errno is set.
61 *
62 * @see tr_fdFileClose
63 */
64int  tr_fdFileCheckout( tr_session             * session,
65                        int                      torrent_id,
66                        tr_file_index_t          file_num,
67                        const char             * existing_dir,
68                        const char             * filename,
69                        bool                  do_write,
70                        tr_preallocation_mode    preallocation_mode,
71                        uint64_t                 preallocation_file_size );
72
73int tr_fdFileGetCached( tr_session             * session,
74                        int                      torrent_id,
75                        tr_file_index_t          file_num,
76                        bool                  doWrite );
77
78bool tr_fdFileGetCachedMTime( tr_session       * session,
79                              int                torrent_id,
80                              tr_file_index_t    file_num,
81                              time_t           * mtime );
82
83
84/**
85 * Closes a file that's being held by our file repository.
86 *
87 * If the file isn't checked out, it's fsync()ed and close()d immediately.
88 * If the file is currently checked out, it will be closed upon its return.
89 *
90 * @see tr_fdFileCheckout
91 */
92void tr_fdFileClose( tr_session        * session,
93                     const tr_torrent  * tor,
94                     tr_file_index_t     file_num );
95
96
97/**
98 * Closes all the files associated with a given torrent id
99 */
100void tr_fdTorrentClose( tr_session * session, int torrentId );
101
102
103/***********************************************************************
104 * Sockets
105 **********************************************************************/
106int      tr_fdSocketCreate( tr_session * session, int domain, int type );
107
108int      tr_fdSocketAccept( tr_session  * session,
109                            int           listening_sockfd,
110                            tr_address  * addr,
111                            tr_port     * port );
112
113void     tr_fdSocketClose( tr_session * session, int s );
114
115/***********************************************************************
116 * tr_fdClose
117 ***********************************************************************
118 * Frees resources allocated by tr_fdInit.
119 **********************************************************************/
120void     tr_fdClose( tr_session * session );
121
122/* @} */
Note: See TracBrowser for help on using the repository browser.