/*
This file is part of GNUnet.
(C) 2012 Christian Grothoff (and other contributing authors)
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 3, or (at your
option) any later version.
GNUnet is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
* @file fs/gnunet-service-fs_stream.c
* @brief non-anonymous file-transfer
* @author Christian Grothoff
*/
#include "platform.h"
#include "gnunet_constants.h"
#include "gnunet_util_lib.h"
#include "gnunet_stream_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
#include "gnunet-service-fs.h"
#include "gnunet-service-fs_indexing.h"
#include "gnunet-service-fs_stream.h"
/**
* After how long do we termiante idle connections?
*/
#define IDLE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 2)
/**
* After how long do we reset connections without replies?
*/
#define CLIENT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
/**
* A message in the queue to be written to the stream.
*/
struct WriteQueueItem
{
/**
* Kept in a DLL.
*/
struct WriteQueueItem *next;
/**
* Kept in a DLL.
*/
struct WriteQueueItem *prev;
/**
* Number of bytes of payload, allocated at the end of this struct.
*/
size_t msize;
};
/**
* Information we keep around for each active streaming client.
*/
struct StreamClient
{
/**
* DLL
*/
struct StreamClient *next;
/**
* DLL
*/
struct StreamClient *prev;
/**
* Socket for communication.
*/
struct GNUNET_STREAM_Socket *socket;
/**
* Handle for active read operation, or NULL.
*/
struct GNUNET_STREAM_ReadHandle *rh;
/**
* Handle for active write operation, or NULL.
*/
struct GNUNET_STREAM_WriteHandle *wh;
/**
* Head of write queue.
*/
struct WriteQueueItem