mirror of
https://github.com/urbit/shrub.git
synced 2024-11-24 13:06:09 +03:00
Merge branch 'master' into https-proxy-config
* master: adds an http request timer to ensure connections are always closed moves u3_pact to vere.h, replacing the unused u3_apac fixes memory leak in failed cttp.c address resolution Remove deprecated paths from gitignore print error on failed syscall in _ce_patch_create() removes tabs from http.c removes orphaned telnet constants and forward declarations
This commit is contained in:
commit
dacb80eef0
2
.gitignore
vendored
2
.gitignore
vendored
@ -12,8 +12,6 @@
|
||||
/outside/**/*.a
|
||||
/outside/re2/obj
|
||||
# build
|
||||
/bin/urbit
|
||||
/bin/test_hash
|
||||
/vere.pkg
|
||||
.tags
|
||||
.etags
|
||||
|
@ -234,15 +234,17 @@
|
||||
void* tls_u; // client SSL_CTX*
|
||||
} u3_cttp;
|
||||
|
||||
/* u3_apac: ames packet, coming or going.
|
||||
/* u3_pact: ames packet, coming or going.
|
||||
*/
|
||||
typedef struct _u3_apac {
|
||||
struct _u3_apac* nex_u; // next in queue
|
||||
c3_w pip_w; // IPv4 address, to
|
||||
c3_s por_s; // IPv4 port, to
|
||||
typedef struct _u3_pact {
|
||||
uv_udp_send_t snd_u; // udp send request
|
||||
c3_w pip_w; // target IPv4 address
|
||||
c3_s por_s; // target port
|
||||
c3_w len_w; // length in bytes
|
||||
c3_y hun_y[0]; // data
|
||||
} u3_apac;
|
||||
c3_y* hun_y; // packet buffer
|
||||
c3_y imp_y; // galaxy number (optional)
|
||||
c3_c* dns_c; // galaxy fqdn (optional)
|
||||
} u3_pact;
|
||||
|
||||
/* u3_ames: ames networking.
|
||||
*/
|
||||
|
@ -276,11 +276,13 @@ _ce_patch_create(u3_ce_patch* pat_u)
|
||||
|
||||
snprintf(ful_c, 8192, "%s/.urb/chk/control.bin", u3P.dir_c);
|
||||
if ( -1 == (pat_u->ctl_i = open(ful_c, O_RDWR | O_CREAT | O_EXCL, 0666)) ) {
|
||||
perror(ful_c);
|
||||
c3_assert(0);
|
||||
}
|
||||
|
||||
snprintf(ful_c, 8192, "%s/.urb/chk/memory.bin", u3P.dir_c);
|
||||
if ( -1 == (pat_u->mem_i = open(ful_c, O_RDWR | O_CREAT | O_EXCL, 0666)) ) {
|
||||
perror(ful_c);
|
||||
c3_assert(0);
|
||||
}
|
||||
}
|
||||
|
24
vere/ames.c
24
vere/ames.c
@ -22,18 +22,6 @@
|
||||
#include "all.h"
|
||||
#include "vere/vere.h"
|
||||
|
||||
/* u3_pact: ames packet struct.
|
||||
*/
|
||||
typedef struct {
|
||||
uv_udp_send_t snd_u;
|
||||
c3_y* buf_y;
|
||||
c3_w len_w;
|
||||
c3_s por_s;
|
||||
c3_w pip_w;
|
||||
c3_y imp_y;
|
||||
c3_c* dns_c;
|
||||
} u3_pact;
|
||||
|
||||
/* _ames_alloc(): libuv buffer allocator.
|
||||
*/
|
||||
static void
|
||||
@ -60,7 +48,7 @@ _ames_free(void* ptr_v)
|
||||
static void
|
||||
_ames_pact_free(u3_pact* pac_u)
|
||||
{
|
||||
free(pac_u->buf_y);
|
||||
free(pac_u->hun_y);
|
||||
free(pac_u->dns_c);
|
||||
free(pac_u);
|
||||
}
|
||||
@ -88,7 +76,7 @@ _ames_send(u3_pact* pac_u)
|
||||
{
|
||||
u3_ames* sam_u = &u3_Host.sam_u;
|
||||
|
||||
if ( !pac_u->buf_y ) {
|
||||
if ( !pac_u->hun_y ) {
|
||||
_ames_pact_free(pac_u);
|
||||
return;
|
||||
}
|
||||
@ -100,7 +88,7 @@ _ames_send(u3_pact* pac_u)
|
||||
add_u.sin_addr.s_addr = htonl(pac_u->pip_w);
|
||||
add_u.sin_port = htons(pac_u->por_s);
|
||||
|
||||
uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->buf_y, pac_u->len_w);
|
||||
uv_buf_t buf_u = uv_buf_init((c3_c*)pac_u->hun_y, pac_u->len_w);
|
||||
|
||||
c3_i sas_i;
|
||||
|
||||
@ -222,6 +210,7 @@ _ames_czar(u3_pact* pac_u, c3_c* bos_c)
|
||||
(now - sam_u->imp_t[pac_u->imp_y]) > 300 ) { /* 5 minute TTL */
|
||||
u3_noun nam = u3dc("scot", 'p', pac_u->imp_y);
|
||||
c3_c* nam_c = u3r_string(nam);
|
||||
// XX remove extra byte for '~'
|
||||
pac_u->dns_c = c3_malloc(1 + strlen(bos_c) + 1 + strlen(nam_c));
|
||||
|
||||
snprintf(pac_u->dns_c, 256, "%s.%s", nam_c + 1, bos_c);
|
||||
@ -302,9 +291,9 @@ u3_ames_ef_send(u3_noun lan, u3_noun pac)
|
||||
|
||||
if ( c3y == _ames_lane_ip(lan, &pac_u->por_s, &pac_u->pip_w) ) {
|
||||
pac_u->len_w = u3r_met(3, pac);
|
||||
pac_u->buf_y = c3_malloc(pac_u->len_w);
|
||||
pac_u->hun_y = c3_malloc(pac_u->len_w);
|
||||
|
||||
u3r_bytes(0, pac_u->len_w, pac_u->buf_y, pac);
|
||||
u3r_bytes(0, pac_u->len_w, pac_u->hun_y, pac);
|
||||
|
||||
if ( 0 == pac_u->pip_w ) {
|
||||
pac_u->pip_w = 0x7f000001;
|
||||
@ -477,6 +466,7 @@ u3_ames_io_exit()
|
||||
{
|
||||
u3_ames* sam_u = &u3_Host.sam_u;
|
||||
|
||||
// XX close wax_u instead
|
||||
uv_close(&sam_u->had_u, 0);
|
||||
}
|
||||
|
||||
|
20
vere/cttp.c
20
vere/cttp.c
@ -841,21 +841,22 @@ _cttp_creq_resolve_cb(uv_getaddrinfo_t* adr_u,
|
||||
u3_creq* ceq_u = adr_u->data;
|
||||
|
||||
if ( u3_csat_quit == ceq_u->sat_e ) {
|
||||
return _cttp_creq_quit(ceq_u);;
|
||||
_cttp_creq_quit(ceq_u);;
|
||||
}
|
||||
|
||||
if ( 0 != sas_i ) {
|
||||
return _cttp_creq_fail(ceq_u, uv_strerror(sas_i));
|
||||
else if ( 0 != sas_i ) {
|
||||
_cttp_creq_fail(ceq_u, uv_strerror(sas_i));
|
||||
}
|
||||
else {
|
||||
// XX traverse struct a la _ames_czar_cb
|
||||
ceq_u->ipf_w = ntohl(((struct sockaddr_in *)aif_u->ai_addr)->sin_addr.s_addr);
|
||||
ceq_u->ipf_c = _cttp_creq_ip(ceq_u->ipf_w);
|
||||
|
||||
ceq_u->ipf_w = ntohl(((struct sockaddr_in *)aif_u->ai_addr)->sin_addr.s_addr);
|
||||
ceq_u->ipf_c = _cttp_creq_ip(ceq_u->ipf_w);
|
||||
ceq_u->sat_e = u3_csat_ripe;
|
||||
_cttp_creq_connect(ceq_u);
|
||||
}
|
||||
|
||||
free(adr_u);
|
||||
uv_freeaddrinfo(aif_u);
|
||||
|
||||
ceq_u->sat_e = u3_csat_ripe;
|
||||
_cttp_creq_connect(ceq_u);
|
||||
}
|
||||
|
||||
/* _cttp_creq_resolve(): resolve hostname to IP address
|
||||
@ -876,6 +877,7 @@ _cttp_creq_resolve(u3_creq* ceq_u)
|
||||
hin_u.ai_socktype = SOCK_STREAM;
|
||||
hin_u.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
// XX is this necessary?
|
||||
c3_c* por_c = ceq_u->por_c ? ceq_u->por_c :
|
||||
( c3y == ceq_u->sec ) ? "443" : "80";
|
||||
|
||||
|
@ -1351,7 +1351,7 @@ u3_http_ef_thou(c3_l sev_l,
|
||||
else if ( !(req_u = _http_req_find(hon_u, seq_l)) ) {
|
||||
if ( bug_w ) {
|
||||
uL(fprintf(uH, "http: request not found: %x/%d/%d\r\n",
|
||||
sev_l, coq_l, seq_l));
|
||||
sev_l, coq_l, seq_l));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -21,19 +21,11 @@
|
||||
#include "vere/vere.h"
|
||||
|
||||
static void _term_spinner_cb(void*);
|
||||
static void _term_read_tn_cb(uv_stream_t* tcp_u,
|
||||
ssize_t siz_i,
|
||||
const uv_buf_t * buf_u);
|
||||
static void _term_read_cb(uv_stream_t* tcp_u,
|
||||
ssize_t siz_i,
|
||||
const uv_buf_t * buf_u);
|
||||
static inline void _term_suck(u3_utty*, const c3_y*, ssize_t);
|
||||
|
||||
|
||||
#define _T_ECHO 1 // local echo
|
||||
#define _T_CTIM 3 // suppress GA/char-at-a-time
|
||||
#define _T_NAWS 31 // negotiate about window size
|
||||
|
||||
#define _SPIN_COOL_US 500000 // spinner activation delay when cool
|
||||
#define _SPIN_WARM_US 50000 // spinner activation delay when warm
|
||||
#define _SPIN_RATE_US 250000 // spinner rate (microseconds/frame)
|
||||
|
Loading…
Reference in New Issue
Block a user