1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +00:00

whitespace/indentation

This commit is contained in:
Jordan Lee 2013-05-23 05:43:12 +00:00
parent f36d705060
commit 5452908346

View file

@ -99,7 +99,8 @@ tr_peerIdInit (uint8_t * buf)
memcpy (buf, PEERID_PREFIX, 8);
tr_cryptoRandBuf (buf+8, 11);
for (i=8; i<19; ++i) {
for (i=8; i<19; ++i)
{
val = buf[i] % base;
total += val;
buf[i] = pool[val];
@ -185,7 +186,8 @@ accept_incoming_peer (int fd, short what UNUSED, void * vsession)
tr_session * session = vsession;
clientSocket = tr_netAccept (session, fd, &clientAddr, &clientPort);
if (clientSocket > 0) {
if (clientSocket > 0)
{
tr_logAddDeep (__FILE__, __LINE__, NULL, "new incoming connection %d (%s)",
clientSocket, tr_peerIoAddrStr (&clientAddr, clientPort));
tr_peerMgrAddIncoming (session->peerMgr, &clientAddr, clientPort,
@ -201,16 +203,19 @@ open_incoming_peer_port (tr_session * session)
/* bind an ipv4 port to listen for incoming peers... */
b = session->public_ipv4;
b->socket = tr_netBindTCP (&b->addr, session->private_peer_port, false);
if (b->socket >= 0) {
if (b->socket >= 0)
{
b->ev = event_new (session->event_base, b->socket, EV_READ | EV_PERSIST, accept_incoming_peer, session);
event_add (b->ev, NULL);
}
/* and do the exact same thing for ipv6, if it's supported... */
if (tr_net_hasIPv6 (session->private_peer_port)) {
if (tr_net_hasIPv6 (session->private_peer_port))
{
b = session->public_ipv6;
b->socket = tr_netBindTCP (&b->addr, session->private_peer_port, false);
if (b->socket >= 0) {
if (b->socket >= 0)
{
b->ev = event_new (session->event_base, b->socket, EV_READ | EV_PERSIST, accept_incoming_peer, session);
event_add (b->ev, NULL);
}
@ -291,7 +296,8 @@ static const char *
format_tos (int value)
{
static char buf[8];
switch (value) {
switch (value)
{
case 0: return "default";
case 0x10: return "lowcost";
case 0x08: return "throughput";
@ -564,10 +570,10 @@ static void tr_sessionInitImpl (void *);
struct init_data
{
tr_session * session;
const char * configDir;
bool done;
bool messageQueuingEnabled;
tr_session * session;
const char * configDir;
tr_variant * clientSettings;
};
@ -645,8 +651,10 @@ onNowTimer (int foo UNUSED, short bar UNUSED, void * vsession)
if (session->turtle.isClockEnabled)
turtleCheckClock (session, &session->turtle);
while ((tor = tr_torrentNext (session, tor))) {
if (tor->isRunning) {
while ((tor = tr_torrentNext (session, tor)))
{
if (tor->isRunning)
{
if (tr_torrentIsSeed (tor))
++tor->secondsSeeding;
else
@ -661,8 +669,10 @@ onNowTimer (int foo UNUSED, short bar UNUSED, void * vsession)
/* schedule the next timer for right after the next second begins */
gettimeofday (&tv, NULL);
usec = 1000000 - tv.tv_usec;
if (usec > max) usec = max;
if (usec < min) usec = min;
if (usec > max)
usec = max;
if (usec < min)
usec = min;
tr_timerAdd (session->nowTimer, 0, usec);
/* fprintf (stderr, "time %zu sec, %zu microsec\n", (size_t)tr_time (), (size_t)tv.tv_usec); */
}
@ -763,7 +773,8 @@ sessionSetImpl (void * vdata)
if (tr_variantDictFindInt (settings, TR_KEY_message_level, &i))
tr_logSetLevel (i);
if (tr_variantDictFindInt (settings, TR_KEY_umask, &i)) {
if (tr_variantDictFindInt (settings, TR_KEY_umask, &i))
{
session->umask = (mode_t)i;
umask (session->umask);
}
@ -1075,11 +1086,9 @@ tr_sessionIsLocked (const tr_session * session)
return tr_isSession (session) && tr_lockHave (session->lock);
}
/***********************************************************************
* tr_setBindPort
***********************************************************************
*
**********************************************************************/
/***
**** Peer Port
***/
static void
peerPortChanged (void * session)
@ -1522,7 +1531,8 @@ tr_sessionUseAltSpeedTime (tr_session * s, bool b)
assert (tr_isSession (s));
assert (tr_isBool (b));
if (t->isClockEnabled != b) {
if (t->isClockEnabled != b)
{
t->isClockEnabled = b;
userPokedTheClock (s, t);
}
@ -1542,7 +1552,8 @@ tr_sessionSetAltSpeedBegin (tr_session * s, int minute)
assert (tr_isSession (s));
assert (0<=minute && minute< (60*24));
if (s->turtle.beginMinute != minute) {
if (s->turtle.beginMinute != minute)
{
s->turtle.beginMinute = minute;
userPokedTheClock (s, &s->turtle);
}
@ -1562,7 +1573,8 @@ tr_sessionSetAltSpeedEnd (tr_session * s, int minute)
assert (tr_isSession (s));
assert (0<=minute && minute< (60*24));
if (s->turtle.endMinute != minute) {
if (s->turtle.endMinute != minute)
{
s->turtle.endMinute = minute;
userPokedTheClock (s, &s->turtle);
}
@ -1581,7 +1593,8 @@ tr_sessionSetAltSpeedDay (tr_session * s, tr_sched_day days)
{
assert (tr_isSession (s));
if (s->turtle.days != days) {
if (s->turtle.days != days)
{
s->turtle.days = days;
userPokedTheClock (s, &s->turtle);
}
@ -1745,10 +1758,10 @@ static void closeBlocklists (tr_session *);
static void
sessionCloseImpl (void * vsession)
{
tr_session * session = vsession;
tr_torrent * tor;
int i, n;
tr_torrent * tor;
tr_torrent ** torrents;
tr_session * session = vsession;
assert (tr_isSession (session));
@ -1778,10 +1791,10 @@ sessionCloseImpl (void * vsession)
tor = NULL;
n = session->torrentCount;
torrents = tr_new (tr_torrent *, session->torrentCount);
for (i = 0; i < n; ++i)
for (i=0; i<n; ++i)
torrents[i] = tor = tr_torrentNext (session, tor);
qsort (torrents, n, sizeof (tr_torrent*), compareTorrentByCur);
for (i = 0; i < n; ++i)
for (i=0; i<n; ++i)
tr_torrentFree (torrents[i]);
tr_free (torrents);
@ -1799,7 +1812,8 @@ sessionCloseImpl (void * vsession)
/* gotta keep udp running long enough to send out all
the &event=stopped UDP tracker messages */
while (!tr_tracker_udp_is_idle (session)) {
while (!tr_tracker_udp_is_idle (session))
{
tr_tracker_udp_upkeep (session);
tr_wait_msec (100);
}
@ -1866,12 +1880,14 @@ tr_sessionClose (tr_session * session)
static bool forced = false;
dbgmsg ("waiting for libtransmission thread to finish... now %zu deadline %zu", (size_t)time (NULL), (size_t)deadline);
tr_wait_msec (100);
if (deadlineReached (deadline) && !forced)
{
dbgmsg ("calling event_loopbreak ()");
forced = true;
event_base_loopbreak (session->event_base);
}
if (deadlineReached (deadline+3))
{
dbgmsg ("deadline+3 reached... calling break...\n");
@ -1884,7 +1900,8 @@ tr_sessionClose (tr_session * session)
tr_bandwidthDestruct (&session->bandwidth);
tr_bitfieldDestruct (&session->turtle.minutes);
tr_lockFree (session->lock);
if (session->metainfoLookup) {
if (session->metainfoLookup)
{
tr_variantFree (session->metainfoLookup);
tr_free (session->metainfoLookup);
}
@ -1949,7 +1966,7 @@ sessionLoadTorrents (void * vdata)
}
data->torrents = tr_new (tr_torrent *, n);
for (i = 0, l = list; l != NULL; l = l->next)
for (i=0, l=list; l!=NULL; l=l->next)
data->torrents[i++] = (tr_torrent*) l->data;
assert (i == n);
@ -2059,6 +2076,7 @@ static void
toggle_utp (void * data)
{
tr_session * session = data;
assert (tr_isSession (session));
session->isUTPEnabled = !session->isUTPEnabled;
@ -2295,8 +2313,7 @@ loadBlocklists (tr_session * session)
static void
closeBlocklists (tr_session * session)
{
tr_list_free (&session->blocklists,
(TrListForeachFunc)tr_blocklistFileFree);
tr_list_free (&session->blocklists, (TrListForeachFunc)tr_blocklistFileFree);
}
void
@ -2311,13 +2328,14 @@ tr_sessionReloadBlocklists (tr_session * session)
int
tr_blocklistGetRuleCount (const tr_session * session)
{
int n = 0;
tr_list * l;
int n = 0;
assert (tr_isSession (session));
for (l = session->blocklists; l; l = l->next)
n += tr_blocklistFileGetRuleCount (l->data);
return n;
}
@ -2359,9 +2377,8 @@ tr_blocklistSetContent (tr_session * session, const char * contentFilename)
const char * defaultName = DEFAULT_BLOCKLIST_FILENAME;
tr_sessionLock (session);
for (b = NULL, l = session->blocklists; !b && l; l = l->next)
if (tr_stringEndsWith (tr_blocklistFileGetFilename (l->data),
defaultName))
for (b=NULL, l=session->blocklists; !b && l; l=l->next)
if (tr_stringEndsWith (tr_blocklistFileGetFilename (l->data), defaultName))
b = l->data;
if (!b)
@ -2388,6 +2405,7 @@ tr_sessionIsAddressBlocked (const tr_session * session,
for (l = session->blocklists; l; l = l->next)
if (tr_blocklistFileHasAddress (l->data, addr))
return true;
return false;
}
@ -2460,9 +2478,11 @@ tr_sessionFindTorrentFile (const tr_session * session,
const char * hashString)
{
const char * filename = NULL;
if (!session->metainfoLookup)
metainfoLookupInit ((tr_session*)session);
tr_variantDictFindStr (session->metainfoLookup, tr_quark_new(hashString,-1), &filename, NULL);
return filename;
}