auth zone work.

git-svn-id: file:///svn/unbound/trunk@4521 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2018-02-08 11:59:30 +00:00
parent 5b41e86d51
commit ad89368b4e
4 changed files with 28 additions and 18 deletions

View file

@ -3766,7 +3766,7 @@ static int
http_zonefile_syntax_check(struct auth_xfer* xfr, sldns_buffer* buf)
{
uint8_t rr[LDNS_RR_BUF_SIZE];
size_t rr_len = 0, dname_len = 0;
size_t rr_len, dname_len = 0;
struct auth_chunk* chunk;
size_t chunk_pos;
int e;
@ -3775,6 +3775,7 @@ http_zonefile_syntax_check(struct auth_xfer* xfr, sldns_buffer* buf)
if(!chunkline_non_comment_RR(&chunk, &chunk_pos, buf)) {
return 0;
}
rr_len = sizeof(rr);
e=sldns_str2wire_rr_buf((char*)sldns_buffer_begin(buf), rr, &rr_len,
&dname_len, 3600, NULL, 0, NULL, 0);
if(e != 0) {
@ -5089,6 +5090,8 @@ auth_xfer_transfer_http_callback(struct comm_point* c, void* arg, int err,
/* if it is good, link it into the list of data */
/* if the link into list of data fails (malloc fail) cleanup and end */
if(sldns_buffer_limit(c->buffer) > 0) {
verbose(VERB_ALGO, "auth zone http queued up %d bytes",
(int)sldns_buffer_limit(c->buffer));
if(!xfer_link_data(c->buffer, xfr)) {
verbose(VERB_ALGO, "http stopped to %s, malloc failed",
xfr->task_transfer->master->host);
@ -5506,6 +5509,18 @@ auth_xfer_timer(void* arg)
/* see if we need to start a probe (or maybe it is already in
* progress (due to notify)) */
if(xfr->task_probe->worker == NULL) {
if(xfr->task_probe->masters == NULL) {
/* useless to pick up task_probe, no masters to
* probe. Instead attempt to pick up task transfer */
if(xfr->task_transfer->worker == NULL) {
xfr_start_transfer(xfr, env, NULL);
} else {
/* task transfer already in progress */
lock_basic_unlock(&xfr->lock);
}
return;
}
/* pick up the probe task ourselves */
xfr->task_probe->worker = env->worker;
xfr->task_probe->env = env;

View file

@ -2327,7 +2327,7 @@ outnet_comm_point_for_http(struct outside_network* outnet,
comm_point_delete(cp);
return NULL;
}
return NULL;
return cp;
}
/** get memory used by waiting tcp entry (in use or not) */

View file

@ -1723,7 +1723,7 @@ http_header_line(sldns_buffer* buf)
/* terminate on the \n and skip past the it and done */
if((char)sldns_buffer_read_u8_at(buf, i) == '\n') {
sldns_buffer_write_u8_at(buf, i, 0);
sldns_buffer_set_position(buf, i);
sldns_buffer_set_position(buf, i+1);
return result;
}
}
@ -1815,11 +1815,6 @@ http_process_chunk_header(struct comm_point* c)
c->tcp_byte_count = (size_t)strtol(line, &end, 16);
if(end == line)
return 0;
c->http_in_chunk_headers = 2;
return 1;
}
if(line[0] == 0) {
/* end of chunk headers */
c->http_in_chunk_headers = 0;
/* remove header text from front of buffer */
http_moveover_buffer(c->buffer);
@ -1828,6 +1823,7 @@ http_process_chunk_header(struct comm_point* c)
/* done with chunks, process chunk_trailer lines */
c->http_in_chunk_headers = 3;
}
return 1;
}
/* ignore other headers */
return 1;
@ -1915,6 +1911,7 @@ http_chunked_segment(struct comm_point* c)
sldns_buffer_write(c->buffer,
sldns_buffer_begin(c->http_temp),
sldns_buffer_remaining(c->http_temp));
sldns_buffer_flip(c->buffer);
/* process end of chunk trailer header lines, until
* an empty line */
c->http_in_chunk_headers = 3;
@ -1955,9 +1952,6 @@ static int
comm_point_http_handle_read(int fd, struct comm_point* c)
{
log_assert(c->type == comm_http);
if(!c->tcp_is_reading)
return 0;
log_assert(fd != -1);
/* if we are in ssl handshake, handle SSL handshake */
@ -1968,6 +1962,8 @@ comm_point_http_handle_read(int fd, struct comm_point* c)
return 1;
}
if(!c->tcp_is_reading)
return 1;
/* read more data */
if(c->ssl) {
if(!ssl_http_read_more(c))
@ -2146,9 +2142,6 @@ static int
comm_point_http_handle_write(int fd, struct comm_point* c)
{
log_assert(c->type == comm_http);
if(c->tcp_is_reading)
return 0;
log_assert(fd != -1);
/* check pending connect errors, if that fails, we wait for more,
@ -2166,6 +2159,8 @@ comm_point_http_handle_write(int fd, struct comm_point* c)
if(c->ssl_shake_state != comm_ssl_shake_none)
return 1;
}
if(c->tcp_is_reading)
return 1;
/* if we are writing, write more */
if(c->ssl) {
if(!ssl_http_write_more(c))
@ -2811,7 +2806,7 @@ comm_point_delete(struct comm_point* c)
{
if(!c)
return;
if(c->type == comm_tcp && c->ssl) {
if((c->type == comm_tcp || c->type == comm_http) && c->ssl) {
#ifdef HAVE_SSL
SSL_shutdown(c->ssl);
SSL_free(c->ssl);
@ -2825,7 +2820,7 @@ comm_point_delete(struct comm_point* c)
free(c->tcp_handlers);
}
free(c->timeout);
if(c->type == comm_tcp || c->type == comm_local) {
if(c->type == comm_tcp || c->type == comm_local || c->type == comm_http) {
sldns_buffer_free(c->buffer);
#ifdef USE_DNSCRYPT
if(c->dnscrypt && c->dnscrypt_buffer != c->buffer) {

View file

@ -206,8 +206,8 @@ struct comm_point {
/* -------- HTTP ------- */
/** Currently reading in http headers */
int http_in_headers;
/** Currently reading in chunk headers, 0=not, 1=firstline, 2=rest
* of chunk header, 3=trailer headers after chunk */
/** Currently reading in chunk headers, 0=not, 1=firstline, 2=unused
* (more lines), 3=trailer headers after chunk */
int http_in_chunk_headers;
/** chunked transfer */
int http_is_chunked;