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;
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) {
/* 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);
/* 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;
comm_point_delete(cp);
return NULL;
}
- return NULL;
+ return cp;
}
/** get memory used by waiting tcp entry (in use or not) */
/* 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;
}
}
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);
/* done with chunks, process chunk_trailer lines */
c->http_in_chunk_headers = 3;
}
+ return 1;
}
/* ignore other headers */
return 1;
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;
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 */
return 1;
}
+ if(!c->tcp_is_reading)
+ return 1;
/* read more data */
if(c->ssl) {
if(!ssl_http_read_more(c))
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,
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))
{
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);
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) {
/* -------- 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;