aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llxfermanager.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llxfermanager.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/llxfermanager.h206
1 files changed, 206 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llxfermanager.h b/linden/indra/llmessage/llxfermanager.h
new file mode 100644
index 0000000..b6e3ee2
--- /dev/null
+++ b/linden/indra/llmessage/llxfermanager.h
@@ -0,0 +1,206 @@
1/**
2 * @file llxfermanager.h
3 * @brief definition of LLXferManager class for a keeping track of
4 * multiple xfers
5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 *
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#ifndef LL_LLXFERMANAGER_H
30#define LL_LLXFERMANAGER_H
31
32/**
33 * this manager keeps both a send list and a receive list; anything with a
34 * LLXferManager can send and receive files via messages
35 */
36
37//Forward declaration to avoid circular dependencies
38class LLXfer;
39class LLVFS;
40
41#include "llxfer.h"
42#include "message.h"
43#include "llassetstorage.h"
44#include "linked_lists.h"
45#include "lldir.h"
46#include "lllinkedqueue.h"
47#include "llthrottle.h"
48
49class LLHostStatus
50{
51 public:
52 LLHost mHost;
53 S32 mNumActive;
54 S32 mNumPending;
55
56 LLHostStatus() {mNumActive = 0; mNumPending = 0;};
57 virtual ~LLHostStatus(){};
58};
59
60// Class stores ack information, to be put on list so we can throttle xfer rate.
61class LLXferAckInfo
62{
63public:
64 LLXferAckInfo(U32 dummy = 0)
65 {
66 mID = 0;
67 mPacketNum = -1;
68 }
69
70 U64 mID;
71 S32 mPacketNum;
72 LLHost mRemoteHost;
73};
74
75class LLXferManager
76{
77 private:
78 LLVFS *mVFS;
79
80 protected:
81 S32 mMaxOutgoingXfersPerCircuit;
82 S32 mMaxIncomingXfers;
83
84 BOOL mUseAckThrottling; // Use ack throttling to cap file xfer bandwidth
85 LLLinkedQueue<LLXferAckInfo> mXferAckQueue;
86 LLThrottle mAckThrottle;
87 public:
88
89 // This enumeration is useful in the requestFile() to specify if
90 // an xfer must happen asap.
91 enum
92 {
93 LOW_PRIORITY = FALSE,
94 HIGH_PRIORITY = TRUE,
95 };
96
97 LLXfer *mSendList;
98 LLXfer *mReceiveList;
99
100 LLLinkedList <LLHostStatus> mOutgoingHosts;
101
102 private:
103 protected:
104 // implementation methods
105 virtual void startPendingDownloads();
106 virtual void addToList(LLXfer* xferp, LLXfer*& head, BOOL is_priority);
107
108 public:
109 LLXferManager(LLVFS *vfs);
110 virtual ~LLXferManager();
111
112 virtual void init(LLVFS *vfs);
113 virtual void free();
114
115 void setUseAckThrottling(const BOOL use);
116 void setAckThrottleBPS(const F32 bps);
117
118// list management routines
119 virtual LLXfer *findXfer(U64 id, LLXfer *list_head);
120 virtual void removeXfer (LLXfer *delp, LLXfer **list_head);
121 virtual U32 numActiveListEntries(LLXfer *list_head);
122 virtual S32 numActiveXfers(const LLHost &host);
123 virtual S32 numPendingXfers(const LLHost &host);
124 virtual void changeNumActiveXfers(const LLHost &host, S32 delta);
125
126 virtual void setMaxOutgoingXfersPerCircuit (S32 max_num);
127 virtual void setMaxIncomingXfers(S32 max_num);
128 virtual void updateHostStatus();
129 virtual void printHostStatus();
130
131// general utility routines
132 virtual void registerCallbacks(LLMessageSystem *mesgsys);
133 virtual U64 getNextID ();
134 virtual S32 encodePacketNum(S32 packet_num, BOOL is_eof);
135 virtual S32 decodePacketNum(S32 packet_num);
136 virtual BOOL isLastPacket(S32 packet_num);
137
138 virtual U64 registerXfer(const void *datap, const S32 length);
139
140// file requesting routines
141// .. to file
142 virtual void requestFile(const char* local_filename,
143 const char* remote_filename,
144 ELLPath remote_path,
145 const LLHost& remote_host,
146 BOOL delete_remote_on_completion,
147 void (*callback)(void**,S32), void** user_data,
148 BOOL is_priority = FALSE,
149 BOOL use_big_packets = FALSE);
150
151// .. to memory
152 virtual void requestFile(const char* remote_filename,
153 ELLPath remote_path,
154 const LLHost &remote_host,
155 BOOL delete_remote_on_completion,
156 void (*callback)(void*, S32, void**, S32),
157 void** user_data,
158 BOOL is_priority = FALSE);
159
160// vfile requesting
161// .. to vfile
162 virtual void requestVFile(const LLUUID &local_id, const LLUUID& remote_id,
163 LLAssetType::EType type, LLVFS* vfs,
164 const LLHost& remote_host,
165 void (*callback)(void**, S32), void** user_data,
166 BOOL is_priority = FALSE);
167
168/*
169// xfer request (may be memory or file)
170// .. to file
171 virtual void requestXfer(const char *local_filename, U64 xfer_id,
172 BOOL delete_remote_on_completion,
173 const LLHost &remote_host, void (*callback)(void **,S32),void **user_data);
174// .. to memory
175 virtual void requestXfer(U64 xfer_id,
176 const LLHost &remote_host,
177 BOOL delete_remote_on_completion,
178 void (*callback)(void *, S32, void **, S32),void **user_data);
179*/
180
181 virtual void processReceiveData (LLMessageSystem *mesgsys, void **user_data);
182 virtual void sendConfirmPacket (LLMessageSystem *mesgsys, U64 id, S32 packetnum, const LLHost &remote_host);
183
184// file sending routines
185 virtual void processFileRequest (LLMessageSystem *mesgsys, void **user_data);
186 virtual void processConfirmation (LLMessageSystem *mesgsys, void **user_data);
187 virtual void retransmitUnackedPackets ();
188
189// error handling
190 virtual void processAbort (LLMessageSystem *mesgsys, void **user_data);
191};
192
193extern LLXferManager* gXferManager;
194
195// initialization and garbage collection
196void start_xfer_manager(LLVFS *vfs);
197void cleanup_xfer_manager();
198
199// message system callbacks
200void process_confirm_packet (LLMessageSystem *mesgsys, void **user_data);
201void process_request_xfer (LLMessageSystem *mesgsys, void **user_data);
202void continue_file_receive(LLMessageSystem *mesgsys, void **user_data);
203void process_abort_xfer (LLMessageSystem *mesgsys, void **user_data);
204#endif
205
206