Mercurial > pidgin.yaz
comparison src/protocols/oscar/snac.c @ 3752:b32474e522fa
[gaim-migrate @ 3890]
From: "William T. Mahan" <wtm2@duke.edu>
This patch, against CVS HEAD, fixes three bugs in Oscar File Transfer
support. I can split it up further if desired.
* Send a null checksum when initiating a file transfer, which fixes
"files don't match" warnings produced by some versions of WinAIM; add
a compile-time option to actually compute the checksum, which is
slow but necessary when sending to some Mac clients.
* Don't allow sending files to oneself, because it causes all kinds of
subtle problems and it's not useful.
* Don't crash when there is an error writing to the output file when
receiving.
From: "William T. Mahan" <wtm2@duke.edu>
This patch 2 of 3, which applies on top of the first, adds support for
reverse connections for Oscar File Transfer, the lack of which has
been the biggest complaint so far. Reverse connections are used by
newer AIM clients when there is difficulty verifying the IP of the
sender.
From: "William T. Mahan" <wtm2@duke.edu>
This patch 3 of 3, which applies on top of the first 2, removes the
alarm() and sigaction() calls that were added by my original FT patch
to detect transfer timeouts. Besides apparently not working on
Windows, they involved a lot of ugly code to handle a special case.
My new approach is to add destructors that can called when SNACs are
freed; a timeout is detected when a request SNAC is cleaned up before
the transfer is accepted. Although this touches several files, it is
more generic than the old method. I tried to implement this in an
unintrusive manner, so that there is little preformance penalty for
SNACs that do not use destructors.
My first two patches should work fine without this. If there are any
objections to the third patch, I ask that the first two patches be
applied, in which case I will set up a SourceForge page for this one.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 19 Oct 2002 05:22:30 +0000 |
parents | d82efea341ef |
children | 765769211688 |
comparison
equal
deleted
inserted
replaced
3751:e25577506dec | 3752:b32474e522fa |
---|---|
87 index = id % FAIM_SNAC_HASH_SIZE; | 87 index = id % FAIM_SNAC_HASH_SIZE; |
88 | 88 |
89 for (prev = (aim_snac_t **)&sess->snac_hash[index]; (cur = *prev); ) { | 89 for (prev = (aim_snac_t **)&sess->snac_hash[index]; (cur = *prev); ) { |
90 if (cur->id == id) { | 90 if (cur->id == id) { |
91 *prev = cur->next; | 91 *prev = cur->next; |
92 if (cur->flags & AIM_SNACFLAGS_DESTRUCTOR) { | |
93 struct aim_snac_destructor *asd = cur->data; | |
94 cur->data = asd->data; | |
95 free(asd); | |
96 } | |
92 return cur; | 97 return cur; |
93 } else | 98 } else |
94 prev = &cur->next; | 99 prev = &cur->next; |
95 } | 100 } |
96 | 101 |
97 return cur; | 102 return cur; |
98 } | 103 } |
104 | |
105 /* Free a SNAC, and call the appropriate destructor if necessary. | |
106 * XXX perhaps this should be inline? -- wtm | |
107 */ | |
108 faim_internal void aim_cleansnac(aim_session_t *sess, aim_snac_t *snac) | |
109 { | |
110 aim_module_t *cur; | |
111 | |
112 if (snac->flags & AIM_SNACFLAGS_DESTRUCTOR) { | |
113 struct aim_snac_destructor *d = snac->data; | |
114 aim_modsnac_t modsnac; | |
115 | |
116 modsnac.id = snac->id; | |
117 modsnac.subtype = snac->type; | |
118 modsnac.family = snac->family; | |
119 modsnac.flags = snac->flags; | |
120 | |
121 for (cur = (aim_module_t *)sess->modlistv; cur; cur = cur->next) | |
122 { | |
123 if (!cur->snacdestructor) | |
124 continue; | |
125 if (!(cur->flags & AIM_MODFLAG_MULTIFAMILY) && | |
126 (cur->family != modsnac.family)) | |
127 continue; | |
128 if (cur->snacdestructor(sess, d->conn, &modsnac, | |
129 d->data)) | |
130 break; | |
131 } | |
132 free(d->data); | |
133 free(d); | |
134 } | |
135 | |
136 free(snac->data); | |
137 free(snac); | |
138 } | |
139 | |
99 | 140 |
100 /* | 141 /* |
101 * This is for cleaning up old SNACs that either don't get replies or | 142 * This is for cleaning up old SNACs that either don't get replies or |
102 * a reply was never received for. Garabage collection. Plain and simple. | 143 * a reply was never received for. Garabage collection. Plain and simple. |
103 * | 144 * |
120 for (prev = (aim_snac_t **)&sess->snac_hash[i]; (cur = *prev); ) { | 161 for (prev = (aim_snac_t **)&sess->snac_hash[i]; (cur = *prev); ) { |
121 if ((curtime - cur->issuetime) > maxage) { | 162 if ((curtime - cur->issuetime) > maxage) { |
122 | 163 |
123 *prev = cur->next; | 164 *prev = cur->next; |
124 | 165 |
125 /* XXX should we have destructors here? */ | 166 aim_cleansnac(sess, cur); |
126 free(cur->data); | |
127 free(cur); | |
128 | |
129 } else | 167 } else |
130 prev = &cur->next; | 168 prev = &cur->next; |
131 } | 169 } |
132 } | 170 } |
133 | 171 |