Removed unhelpful coding errors.

This commit is contained in:
frekky 2015-08-21 23:24:53 +08:00
parent d8c08191cc
commit 96f9270b7f
3 changed files with 16 additions and 15 deletions

View File

@ -397,7 +397,6 @@ send_next_frag(int fd)
/* Get next fragment to send */ /* Get next fragment to send */
f = window_get_next_sending_fragment(outbuf, next_downstream_ack); f = window_get_next_sending_fragment(outbuf, next_downstream_ack);
window_tick(outbuf);
if (f == NULL) { if (f == NULL) {
if (is_sending()) { if (is_sending()) {
/* There is stuff to send but we're out of sync, so send a ping /* There is stuff to send but we're out of sync, so send a ping
@ -433,6 +432,8 @@ send_next_frag(int fd)
datacmc = 0; datacmc = 0;
send_query(fd, (char *)buf); send_query(fd, (char *)buf);
window_tick(outbuf);
} }
static void static void

View File

@ -135,12 +135,16 @@ find_available_user()
for (int u = 0; u < usercount; u++) { for (int u = 0; u < usercount; u++) {
/* Not used at all or not used in one minute */ /* Not used at all or not used in one minute */
if (!user_active(u)) { if (!user_active(u)) {
struct tun_user *user = &users[u];
if (user->incoming) window_buffer_destroy(user->incoming);
if (user->outgoing) window_buffer_destroy(user->outgoing);
/* reset all stats */ /* reset all stats */
memset(&users[u], 0, sizeof(users[u])); user->active = 1;
users[u].active = 1; user->authenticated = 0;
users[u].last_pkt = time(NULL); user->authenticated_raw = 0;
users[u].fragsize = MAX_FRAGSIZE; user->last_pkt = time(NULL);
users[u].conn = CONN_DNS_NULL; user->fragsize = MAX_FRAGSIZE;
user->conn = CONN_DNS_NULL;
return u; return u;
} }
} }
@ -177,12 +181,7 @@ check_user_and_ip(int userid, struct query *q)
if (userid < 0 || userid >= created_users ) { if (userid < 0 || userid >= created_users ) {
return 1; return 1;
} }
if (!users[userid].active || users[userid].disabled) { if (!user_active(userid)) return 1;
return 1;
}
if (users[userid].last_pkt + 60 < time(NULL)) {
return 1;
}
/* return early if IP checking is disabled */ /* return early if IP checking is disabled */
if (!check_ip) { if (!check_ip) {

View File

@ -56,7 +56,8 @@ window_buffer_init(size_t length, unsigned windowsize, unsigned fragsize, int di
void void
window_buffer_destroy(struct frag_buffer *w) window_buffer_destroy(struct frag_buffer *w)
{ {
free(w->frags); if (!w) return;
if (w->frags) free(w->frags);
free(w); free(w);
} }
@ -120,7 +121,7 @@ window_reassemble_data(struct frag_buffer *w, uint8_t *data, unsigned maxlen, in
// warnx("chunk_start pointing to non-start fragment (%u)!", w->frags[w->chunk_start].seqID); // warnx("chunk_start pointing to non-start fragment (%u)!", w->frags[w->chunk_start].seqID);
return 0; return 0;
} }
*compression = 1; if (compression) *compression = 1;
fragment *f; fragment *f;
size_t i, curseq; size_t i, curseq;
@ -139,7 +140,7 @@ window_reassemble_data(struct frag_buffer *w, uint8_t *data, unsigned maxlen, in
memcpy(dest, f->data, MIN(fraglen, maxlen)); memcpy(dest, f->data, MIN(fraglen, maxlen));
dest += fraglen; dest += fraglen;
datalen += fraglen; datalen += fraglen;
*compression &= f->compressed & 1; if (compression) *compression &= f->compressed & 1;
if (f->compressed != *compression) { if (f->compressed != *compression) {
warnx("Inconsistent compression flags in chunk. Not reassembling!"); warnx("Inconsistent compression flags in chunk. Not reassembling!");
return 0; return 0;