|
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_t * | upload_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_t * | upload_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_t * | cast_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_key * | mi_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_val * | mi_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_t * | get_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_t * | get_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_t * | get_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_t * | upload_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_t * | upload_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 |