Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

uploads.c File Reference


Detailed Description

Handles upload of our files to others users.

Author:
Raphael Manfredi
Date:
2001-2003
Author:
Daniel Walker (dwalker@cats.ucsc.edu)
Date:
2000

#include "common.h"
#include "uploads.h"
#include "sockets.h"
#include "share.h"
#include "hosts.h"
#include "bsched.h"
#include "upload_stats.h"
#include "dmesh.h"
#include "http.h"
#include "version.h"
#include "nodes.h"
#include "ioheader.h"
#include "ban.h"
#include "parq.h"
#include "huge.h"
#include "settings.h"
#include "features.h"
#include "geo_ip.h"
#include "ggep.h"
#include "ggep_type.h"
#include "gmsg.h"
#include "ignore.h"
#include "tx_link.h"
#include "tx_deflate.h"
#include "if/gnet_property.h"
#include "if/gnet_property_priv.h"
#include "if/bridge/c2ui.h"
#include "lib/aging.h"
#include "lib/atoms.h"
#include "lib/cq.h"
#include "lib/endian.h"
#include "lib/idtable.h"
#include "lib/getdate.h"
#include "lib/getline.h"
#include "lib/glib-missing.h"
#include "lib/file.h"
#include "lib/header.h"
#include "lib/listener.h"
#include "lib/tm.h"
#include "lib/url.h"
#include "lib/urn.h"
#include "lib/utf8.h"
#include "lib/walloc.h"
#include "lib/override.h"

Data Structures

struct  mesh_info_key
 This structure is the key used in the mesh_info hash table to record when we last sent mesh information to some IP about a given file (identified by its SHA1). More...

struct  mesh_info_val

Defines

#define READ_BUF_SIZE   4096 /**< Read buffer size, if no sendfile(2) */
 Read buffer size, if no sendfile(2).

#define BW_OUT_MIN   256 /**< Minimum bandwidth to enable uploads */
 Minimum bandwidth to enable uploads.

#define IO_PRE_STALL   30 /**< Pre-stalling warning */
 Pre-stalling warning.

#define IO_STALLED   60 /**< Stalling condition */
 Stalling condition.

#define IO_LONG_TIMEOUT   160 /**< Longer timeouting condition */
 Longer timeouting condition.

#define UP_SEND_BUFSIZE   1024 /**< Socket write buffer, when stalling */
 Socket write buffer, when stalling.

#define STALL_CLEAR   600 /**< Decrease stall counter every 10 min */
 Decrease stall counter every 10 min.

#define STALL_THRESH   3 /**< If more stalls than that, workaround */
 If more stalls than that, workaround.

#define RQST_LINE_LENGTH   256 /**< Reasonable estimate for request line */
 Reasonable estimate for request line.

#define upload_find_by_handle(n)   (gnutella_upload_t *) idtable_get_value(upload_handle_map, n)
#define upload_new_handle(n)   idtable_new_id(upload_handle_map, n)
#define upload_free_handle(n)   idtable_free_id(upload_handle_map, n);
#define MESH_INFO_TIMEOUT   ((PARQ_MAX_UL_RETRY_DELAY + PARQ_GRACE_TIME)*1000)
#define STALL_FIRST   GUINT_TO_POINTER(0x1)
#define STALL_AGAIN   GUINT_TO_POINTER(0x2)
#define UPLOAD(x)   cast_to_upload(x)

Functions

 RCSID ("$Id:uploads.c, v 1.130 2006/01/01 19:09:03 rmanfredi Exp $")
void upload_request (gnutella_upload_t *u, header_t *header)
 Called to initiate the upload once all the HTTP headers have been read.

void upload_error_remove (gnutella_upload_t *u, struct shared_file *sf, int code, const gchar *msg,...) G_GNUC_PRINTF(4
 Utility routine.

void upload_error_remove_ext (gnutella_upload_t *u, struct shared_file *sf, const gchar *extended, int code, const gchar *msg,...) G_GNUC_PRINTF(5
 Utility routine.

void upload_http_sha1_add (gchar *buf, gint *retval, gpointer arg, guint32 flags)
 This routine is called by http_send_status() to generate the SHA1-specific headers (added to the HTTP status) into `buf'.

void upload_http_xhost_add (gchar *buf, gint *retval, gpointer arg, guint32 flags)
 This routine is called by http_send_status() to generate the X-Host line (added to the HTTP status) into `buf'.

void upload_xfeatures_add (gchar *buf, gint *retval, gpointer arg, guint32 flags)
void upload_writable (gpointer up, gint source, inputevt_cond_t cond)
 Called when output source can accept more data.

void upload_special_writable (gpointer up)
 Called when output source can accept more data.

void send_upload_error (gnutella_upload_t *u, struct shared_file *sf, int code, const gchar *msg,...) G_GNUC_PRINTF(4
 Send error message to requestor.

void upload_add_upload_added_listener (upload_added_listener_t l)
void upload_remove_upload_added_listener (upload_added_listener_t l)
void upload_add_upload_removed_listener (upload_removed_listener_t l)
void upload_remove_upload_removed_listener (upload_removed_listener_t l)
void upload_add_upload_info_changed_listener (upload_info_changed_listener_t l)
void upload_remove_upload_info_changed_listener (upload_info_changed_listener_t l)
void upload_fire_upload_added (gnutella_upload_t *n)
void upload_fire_upload_removed (gnutella_upload_t *n, const gchar *reason)
void upload_fire_upload_info_changed (gnutella_upload_t *n)
guint32 stall_thresh (void)
 Dynamically computed stalling threshold.

gboolean use_sendfile (gnutella_upload_t *u)
 Can we use bio_sendfile()?

void upload_timer (time_t now)
 Upload heartbeat timer.

gnutella_upload_tupload_create (struct gnutella_socket *s, gboolean push)
 Create a new upload structure, linked to a socket.

void upload_send_giv (const host_addr_t addr, guint16 port, guint8 hops, guint8 ttl, guint32 file_index, const gchar *file_name, gboolean banning, guint32 flags)
 Send a GIV string to the specified IP:port.

void handle_push_request (struct gnutella_node *n)
 Called when we receive a Push request on Gnet.

void upload_real_remove (void)
void upload_free_resources (gnutella_upload_t *u)
gnutella_upload_tupload_clone (gnutella_upload_t *u)
 Clone upload, resetting all dynamically allocated structures in the original, since they are shallow-copied to the new upload.

gboolean upload_likely_from_browser (header_t *header)
 Check whether the request was likely made from a browser.

void send_upload_error_v (gnutella_upload_t *u, struct shared_file *sf, const gchar *ext, int code, const gchar *msg, va_list ap)
 The vectorized (message-wise) version of send_upload_error().

void upload_remove_v (gnutella_upload_t *u, const gchar *reason, va_list ap)
 The vectorized (message-wise) version of upload_remove().

void upload_remove (gnutella_upload_t *u, const gchar *reason,...)
 Remove upload entry, log reason.

void upload_stop_all (struct dl_file_info *fi, const gchar *reason)
 Stop all uploads dealing with partial file `fi'.

gnutella_upload_tcast_to_upload (gpointer p)
void err_line_too_long (gpointer obj)
void err_header_error_tell (gpointer obj, gint error)
void err_header_error (gpointer obj, gint error)
void err_input_exception (gpointer obj)
void err_input_buffer_full (gpointer obj)
void err_header_read_error (gpointer obj, gint error)
void err_header_read_eof (gpointer obj)
void err_header_extra_data (gpointer obj)
void call_upload_request (gpointer obj, header_t *header)
mesh_info_keymi_key_make (const host_addr_t addr, const gchar *sha1)
void mi_key_free (struct mesh_info_key *mik)
guint mi_key_hash (gconstpointer key)
gint mi_key_eq (gconstpointer a, gconstpointer b)
mesh_info_valmi_val_make (guint32 stamp)
void mi_val_free (struct mesh_info_val *miv)
void mi_free_kv (gpointer key, gpointer value, gpointer unused_udata)
 Hash table iterator callback.

void mi_clean (cqueue_t *unused_cq, gpointer obj)
 Callout queue callback invoked to clear the entry.

guint32 mi_get_stamp (const host_addr_t addr, const gchar *sha1, time_t now)
 Get timestamp at which we last sent download mesh information for (IP,SHA1).

void upload_add (struct gnutella_socket *s)
 Create a new upload request, and begin reading HTTP headers.

void expect_http_header (gnutella_upload_t *u, upload_stage_t new_status)
 Prepare reception of a full HTTP header, including the leading request.

void upload_wait_new_request (gnutella_upload_t *u)
 This is used for HTTP/1.1 persistent connections.

void upload_connect_conf (gnutella_upload_t *u)
 Got confirmation that the connection to the remote host was OK.

ssize_t sha1_offset_in_uri (const gchar *uri, size_t *length)
 Compute the offset at which the base32 SHA1 representation starts in the "urn:sha1" or "urn:bitprint" URN.

gboolean sha1_extract_from_uri (const gchar *uri, gchar *digest, gboolean *malformed)
 Extract the SHA1 digest out of a "urn:sha1" or "urn:bitprint" URN.

void upload_error_not_found (gnutella_upload_t *u, const gchar *request)
 Send back an HTTP error 404: file not found, We try to pretty-print SHA1 URNs for PFSP files we no longer share...

gboolean upload_http_version (gnutella_upload_t *u, gchar *request, gint len)
 Check that we got an HTTP request, extracting the protocol version.

gboolean upload_file_present (gnutella_upload_t *u, struct shared_file *sf, const gchar *uri)
 Make sure file to upload is still present on disk.

shared_file_tget_file_to_upload_from_index (gnutella_upload_t *u, header_t *header, const gchar *uri, guint idx)
 Get the shared_file to upload.

shared_file_tget_file_to_upload_from_urn (gnutella_upload_t *u, header_t *header, const gchar *uri)
 Get the shared_file to upload from a given URN.

shared_file_tget_file_to_upload (gnutella_upload_t *u, header_t *header, gchar *uri, gchar *search)
 A dispatcher function to call either get_file_to_upload_from_index or get_file_to_upload_from_sha1 depending on the syntax of the request.

void upload_416_extra (gchar *buf, gint *retval, gpointer arg, guint32 unused_flags)
 This routine is called by http_send_status() to generate the additionnal headers on a "416 Request range not satisfiable" error.

void upload_http_status (gchar *buf, gint *retval, gpointer arg, guint32 unused_flags)
 This routine is called by http_send_status() to generate the upload-specific headers into `buf'.

void upload_tx_error (gpointer o, const gchar *reason,...)
void upload_tx_add_written (gpointer o, gint amount)
gint select_encoding (header_t *header)
 Check whether remote end supports deflate or gzip, using a combination of both HTTP headers and User-Agent to screen out known-to-be-broken agents.

gboolean prepare_browsing (gnutella_upload_t *u, header_t *header, const gchar *method, const gchar *host, time_t now, http_extra_desc_t *hev, size_t hevlen, size_t *hevsize, gint *flags)
 Prepare the browse host request.

void upload_completed (gnutella_upload_t *u)
gboolean upload_handle_exception (gnutella_upload_t *u, inputevt_cond_t cond)
ssize_t upload_special_read (gnutella_upload_t *u)
ssize_t upload_special_write (gnutella_upload_t *u, gpointer data, size_t len)
void upload_special_flushed (gpointer arg)
 Callback invoked when the special stack has been fully flushed.

void upload_special_flush (gnutella_upload_t *u)
void upload_kill (gnet_upload_t upload)
 Kill a running upload.

void upload_kill_addr (const host_addr_t addr)
 Kill all running uploads by IP.

gboolean upload_is_enabled (void)
 Check whether uploading is enabled: we have slots, and bandwidth.

void upload_init (void)
 Initialize uploads.

void upload_close (void)
 Final cleanup at shutdown time.

gnet_upload_info_tupload_get_info (gnet_upload_t uh)
void upload_free_info (gnet_upload_info_t *info)
void upload_get_status (gnet_upload_t uh, gnet_upload_status_t *si)

Variables

GSList * list_uploads = NULL
guint stalled = 0
 Counts stalled connections.

time_t last_stalled
 Time at which last stall occurred.

gboolean sendfile_failed = FALSE
 Used to fall back to write() if sendfile() failed.

idtable_tupload_handle_map = NULL
const gchar no_reason [] = "<no reason>"
gint running_uploads = 0
gint registered_uploads = 0
GHashTable * mesh_info = NULL
gpointer stalling_uploads = NULL
listeners_t upload_added_listeners = NULL
listeners_t upload_removed_listeners = NULL
listeners_t upload_info_changed_listeners = NULL
const struct io_error upload_io_error
tx_deflate_cb upload_tx_deflate_cb
tx_link_cb upload_tx_link_cb


Define Documentation

#define BW_OUT_MIN   256 /**< Minimum bandwidth to enable uploads */
 

Minimum bandwidth to enable uploads.

#define IO_LONG_TIMEOUT   160 /**< Longer timeouting condition */
 

Longer timeouting condition.

#define IO_PRE_STALL   30 /**< Pre-stalling warning */
 

Pre-stalling warning.

#define IO_STALLED   60 /**< Stalling condition */
 

Stalling condition.

#define MESH_INFO_TIMEOUT   ((PARQ_MAX_UL_RETRY_DELAY + PARQ_GRACE_TIME)*1000)
 

#define READ_BUF_SIZE   4096 /**< Read buffer size, if no sendfile(2) */
 

Read buffer size, if no sendfile(2).

#define RQST_LINE_LENGTH   256 /**< Reasonable estimate for request line */
 

Reasonable estimate for request line.

#define STALL_AGAIN   GUINT_TO_POINTER(0x2)
 

#define STALL_CLEAR   600 /**< Decrease stall counter every 10 min */
 

Decrease stall counter every 10 min.

#define STALL_FIRST   GUINT_TO_POINTER(0x1)
 

#define STALL_THRESH   3 /**< If more stalls than that, workaround */
 

If more stalls than that, workaround.

#define UP_SEND_BUFSIZE   1024 /**< Socket write buffer, when stalling */
 

Socket write buffer, when stalling.

#define UPLOAD  )     cast_to_upload(x)
 

#define upload_find_by_handle  )     (gnutella_upload_t *) idtable_get_value(upload_handle_map, n)
 

#define upload_free_handle  )     idtable_free_id(upload_handle_map, n);
 

#define upload_new_handle  )     idtable_new_id(upload_handle_map, n)
 


Function Documentation

void call_upload_request gpointer  obj,
header_t header
[static]
 

gnutella_upload_t* cast_to_upload gpointer  p  )  [inline, static]
 

void err_header_error gpointer  obj,
gint  error
[static]
 

void err_header_error_tell gpointer  obj,
gint  error
[static]
 

void err_header_extra_data gpointer  obj  )  [static]
 

void err_header_read_eof gpointer  obj  )  [static]
 

void err_header_read_error gpointer  obj,
gint  error
[static]
 

void err_input_buffer_full gpointer  obj  )  [static]
 

void err_input_exception gpointer  obj  )  [static]
 

void err_line_too_long gpointer  obj  )  [static]
 

void expect_http_header gnutella_upload_t u,
upload_stage_t  new_status
 

Prepare reception of a full HTTP header, including the leading request.

Will call upload_request() when everything has been parsed.

shared_file_t* get_file_to_upload gnutella_upload_t u,
header_t header,
gchar *  uri,
gchar *  search
[static]
 

A dispatcher function to call either get_file_to_upload_from_index or get_file_to_upload_from_sha1 depending on the syntax of the request.

Parameters:
u a valid gnutella_upload_t.
header a valid header_t.
uri the URI part of the HTTP request, URL-encoding has already been decoded.
search the search part of the HTTP request or NULL if none. This string is still URL-encoded to preserve the '&' boundaries.
Returns:
the shared_file if we got it, or NULL otherwise. When NULL is returned, we have sent the error back to the client.

shared_file_t* get_file_to_upload_from_index gnutella_upload_t u,
header_t header,
const gchar *  uri,
guint  idx
[static]
 

Get the shared_file to upload.

"/get/<index>/" has already been extracted, ``uri'' points to the filename after this. The same holds for the file index, which is passed as ``idx''.

Returns:
the shared_file if found, NULL otherwise.

shared_file_t* get_file_to_upload_from_urn gnutella_upload_t u,
header_t header,
const gchar *  uri
[static]
 

Get the shared_file to upload from a given URN.

Returns:
the shared_file if we have it, NULL otherwise

void handle_push_request struct gnutella_node n  ) 
 

Called when we receive a Push request on Gnet.

If it is not for us, discard it. If we are the target, then connect back to the remote servent.

void mi_clean cqueue_t unused_cq,
gpointer  obj
[static]
 

Callout queue callback invoked to clear the entry.

void mi_free_kv gpointer  key,
gpointer  value,
gpointer  unused_udata
[static]
 

Hash table iterator callback.

guint32 mi_get_stamp const host_addr_t  addr,
const gchar *  sha1,
time_t  now
[static]
 

Get timestamp at which we last sent download mesh information for (IP,SHA1).

If we don't remember sending it, return 0. Always records `now' as the time we sent mesh information.

gint mi_key_eq gconstpointer  a,
gconstpointer  b
[static]
 

void mi_key_free struct mesh_info_key mik  )  [static]
 

guint mi_key_hash gconstpointer  key  )  [static]
 

struct mesh_info_key* mi_key_make const host_addr_t  addr,
const gchar *  sha1
[static]
 

void mi_val_free struct mesh_info_val miv  )  [static]
 

struct mesh_info_val* mi_val_make guint32  stamp  )  [static]
 

gboolean prepare_browsing gnutella_upload_t u,
header_t header,
const gchar *  method,
const gchar *  host,
time_t  now,
http_extra_desc_t hev,
size_t  hevlen,
size_t *  hevsize,
gint *  flags
[static]
 

Prepare the browse host request.

Returns:
TRUE if we may go on, FALSE if we've replied to the remote host and either expect a new request now or terminated the connection.

RCSID "$Id:uploads.  c,
v 1.130 2006/01/01 19:09:03 rmanfredi Exp $" 
 

gint select_encoding header_t header  )  [static]
 

Check whether remote end supports deflate or gzip, using a combination of both HTTP headers and User-Agent to screen out known-to-be-broken agents.

Returns:
The chosen compression method. 0: no compression, BH_GZIP: gzip, BH_DEFLATE: deflate

void send_upload_error gnutella_upload_t u,
struct shared_file sf,
int  code,
const gchar *  msg,
... 
[static]
 

Send error message to requestor.

This can only be done once per connection.

void send_upload_error_v gnutella_upload_t u,
struct shared_file sf,
const gchar *  ext,
int  code,
const gchar *  msg,
va_list  ap
[static]
 

The vectorized (message-wise) version of send_upload_error().

gboolean sha1_extract_from_uri const gchar *  uri,
gchar *  digest,
gboolean *  malformed
[static]
 

Extract the SHA1 digest out of a "urn:sha1" or "urn:bitprint" URN.

Parameters:
uri the URI from which we wish to extract the SHA1 digest
digest a SHA1_RAW_SIZE array where digest is written.
malformed only set when returning FALSE, to indicate malformation
Returns:
TRUE if we correctly figured out the SHA1 digest, otherwise set `malformed' to TRUE if we expected a valid SHA1 but were not able to properly decode it, and set `malformed' to FALSE if the URI was not an URN form we recognize as bearing a SHA1.

ssize_t sha1_offset_in_uri const gchar *  uri,
size_t *  length
[static]
 

Compute the offset at which the base32 SHA1 representation starts in the "urn:sha1" or "urn:bitprint" URN.

Parameters:
uri the URI to parse
length filled with expected length of URN, if not NULL
Returns:
the offset at which the SHA1 starts with a filled-in `length', or -1 if it's not a recognized URN.

guint32 stall_thresh void   )  [inline, static]
 

Dynamically computed stalling threshold.

It is half the amount of upload slots configured, with a minimum value of STALL_THRESH.

void upload_416_extra gchar *  buf,
gint *  retval,
gpointer  arg,
guint32  unused_flags
[static]
 

This routine is called by http_send_status() to generate the additionnal headers on a "416 Request range not satisfiable" error.

void upload_add struct gnutella_socket s  ) 
 

Create a new upload request, and begin reading HTTP headers.

void upload_add_upload_added_listener upload_added_listener_t  l  ) 
 

void upload_add_upload_info_changed_listener upload_info_changed_listener_t  l  ) 
 

void upload_add_upload_removed_listener upload_removed_listener_t  l  ) 
 

gnutella_upload_t* upload_clone gnutella_upload_t u  )  [static]
 

Clone upload, resetting all dynamically allocated structures in the original, since they are shallow-copied to the new upload.

(This routine is used because each different upload from the same host will become a line in the GUI, and the GUI stores upload structures in its row data, and will call upload_remove() to clear them.)

void upload_close void   ) 
 

Final cleanup at shutdown time.

void upload_completed gnutella_upload_t u  )  [static]
 

void upload_connect_conf gnutella_upload_t u  ) 
 

Got confirmation that the connection to the remote host was OK.

Send the GIV/QUEUE string, then prepare receiving back the HTTP request.

gnutella_upload_t* upload_create struct gnutella_socket s,
gboolean  push
 

Create a new upload structure, linked to a socket.

void upload_error_not_found gnutella_upload_t u,
const gchar *  request
[static]
 

Send back an HTTP error 404: file not found, We try to pretty-print SHA1 URNs for PFSP files we no longer share...

void upload_error_remove gnutella_upload_t u,
struct shared_file sf,
int  code,
const gchar *  msg,
... 
[static]
 

Utility routine.

Cancel the upload, sending back the HTTP error message.

Note:
The parameter "msg" is passed to gettext(). Do not pass already translated strings because it's send as HTTP response message.

void upload_error_remove_ext gnutella_upload_t u,
struct shared_file sf,
const gchar *  ext,
int  code,
const gchar *  msg,
... 
[static]
 

Utility routine.

Cancel the upload, sending back the HTTP error message. `ext' contains additionnal header information to propagate back.

gboolean upload_file_present gnutella_upload_t u,
struct shared_file sf,
const gchar *  uri
[static]
 

Make sure file to upload is still present on disk.

Returns:
TRUE if OK, FALSE otherwise with the upload removed.

void upload_fire_upload_added gnutella_upload_t n  )  [static]
 

void upload_fire_upload_info_changed gnutella_upload_t n  ) 
 

void upload_fire_upload_removed gnutella_upload_t n,
const gchar *  reason
[static]
 

void upload_free_info gnet_upload_info_t info  ) 
 

void upload_free_resources gnutella_upload_t u  )  [static]
 

gnet_upload_info_t* upload_get_info gnet_upload_t  uh  ) 
 

void upload_get_status gnet_upload_t  uh,
gnet_upload_status_t si
 

gboolean upload_handle_exception gnutella_upload_t u,
inputevt_cond_t  cond
[static]
 

Returns:
TRUE if an exception occured, the upload has been removed in this case. FALSE if everything is OK.

void upload_http_sha1_add gchar *  buf,
gint *  retval,
gpointer  arg,
guint32  flags
[static]
 

This routine is called by http_send_status() to generate the SHA1-specific headers (added to the HTTP status) into `buf'.

void upload_http_status gchar *  buf,
gint *  retval,
gpointer  arg,
guint32  unused_flags
[static]
 

This routine is called by http_send_status() to generate the upload-specific headers into `buf'.

gboolean upload_http_version gnutella_upload_t u,
gchar *  request,
gint  len
[static]
 

Check that we got an HTTP request, extracting the protocol version.

Returns:
TRUE if ok or FALSE otherwise (upload must then be aborted)

void upload_http_xhost_add gchar *  buf,
gint *  retval,
gpointer  unused_arg,
guint32  unused_flags
[static]
 

This routine is called by http_send_status() to generate the X-Host line (added to the HTTP status) into `buf'.

void upload_init void   ) 
 

Initialize uploads.

gboolean upload_is_enabled void   ) 
 

Check whether uploading is enabled: we have slots, and bandwidth.

void upload_kill gnet_upload_t  upload  ) 
 

Kill a running upload.

void upload_kill_addr const host_addr_t  addr  ) 
 

Kill all running uploads by IP.

gboolean upload_likely_from_browser header_t header  )  [static]
 

Check whether the request was likely made from a browser.

void upload_real_remove void   ) 
 

void upload_remove gnutella_upload_t u,
const gchar *  reason,
... 
 

Remove upload entry, log reason.

If no status has been sent back on the HTTP stream yet, give them a 400 error with the reason.

void upload_remove_upload_added_listener upload_added_listener_t  l  ) 
 

void upload_remove_upload_info_changed_listener upload_info_changed_listener_t  l  ) 
 

void upload_remove_upload_removed_listener upload_removed_listener_t  l  ) 
 

void upload_remove_v gnutella_upload_t u,
const gchar *  reason,
va_list  ap
[static]
 

The vectorized (message-wise) version of upload_remove().

void upload_request gnutella_upload_t u,
header_t header
[static]
 

Called to initiate the upload once all the HTTP headers have been read.

Validate the request, and begin processing it if all OK. Otherwise cancel the upload.

void upload_send_giv const host_addr_t  addr,
guint16  port,
guint8  hops,
guint8  ttl,
guint32  file_index,
const gchar *  file_name,
gboolean  banning,
guint32  flags
 

Send a GIV string to the specified IP:port.

`ip' and `port' is where we need to connect. `hops' and `ttl' are the values from the PUSH message we received, just for logging in case we cannot connect. `file_index' and `file_name' are the values we determined from PUSH. `banning' must be TRUE when we determined connections to the IP were currently prohibited.

void upload_special_flush gnutella_upload_t u  )  [inline, static]
 

void upload_special_flushed gpointer  arg  )  [static]
 

Callback invoked when the special stack has been fully flushed.

ssize_t upload_special_read gnutella_upload_t u  )  [inline, static]
 

void upload_special_writable gpointer  up  )  [static]
 

Called when output source can accept more data.

ssize_t upload_special_write gnutella_upload_t u,
gpointer  data,
size_t  len
[inline, static]
 

void upload_stop_all struct dl_file_info fi,
const gchar *  reason
 

Stop all uploads dealing with partial file `fi'.

void upload_timer time_t  now  ) 
 

Upload heartbeat timer.

void upload_tx_add_written gpointer  o,
gint  amount
[static]
 

void upload_tx_error gpointer  o,
const gchar *  reason,
... 
[static]
 

void upload_wait_new_request gnutella_upload_t u  )  [static]
 

This is used for HTTP/1.1 persistent connections.

Move the upload back to a waiting state, until a new HTTP request comes on the socket.

void upload_writable gpointer  up,
gint  unused_source,
inputevt_cond_t  cond
[static]
 

Called when output source can accept more data.

< For sendfile() sanity checks

void upload_xfeatures_add gchar *  buf,
gint *  retval,
gpointer  unused_arg,
guint32  unused_flags
[static]
 

gboolean use_sendfile gnutella_upload_t u  )  [inline, static]
 

Can we use bio_sendfile()?


Variable Documentation

time_t last_stalled [static]
 

Time at which last stall occurred.

GSList* list_uploads = NULL [static]
 

GHashTable* mesh_info = NULL [static]
 

const gchar no_reason[] = "<no reason>" [static]
 

gint registered_uploads = 0 [static]
 

gint running_uploads = 0 [static]
 

gboolean sendfile_failed = FALSE [static]
 

Used to fall back to write() if sendfile() failed.

guint stalled = 0 [static]
 

Counts stalled connections.

gpointer stalling_uploads = NULL [static]
 

listeners_t upload_added_listeners = NULL [static]
 

idtable_t* upload_handle_map = NULL [static]
 

listeners_t upload_info_changed_listeners = NULL [static]
 

const struct io_error upload_io_error [static]
 

Initial value:

 {
    err_line_too_long,
    err_header_error_tell,
    err_header_error,
    err_input_exception,
    err_input_buffer_full,
    err_header_read_error,
    err_header_read_eof,
    err_header_extra_data,
}

listeners_t upload_removed_listeners = NULL [static]
 

struct tx_deflate_cb upload_tx_deflate_cb [static]
 

Initial value:

 {
    NULL,               
    upload_tx_error,    
}

struct tx_link_cb upload_tx_link_cb [static]
 

Initial value:

 {
    upload_tx_add_written,  
    upload_tx_error,        
    upload_tx_error,        
    NULL,                   
}


Generated on Sun Feb 12 10:50:09 2006 for Gtk-Gnutella by doxygen 1.3.6