comparison dbutil.c @ 1027:daf21fd50abf fastopen

In theory TFO should work. Needs platform cleanup and testing
author Matt Johnston <matt@ucc.asn.au>
date Thu, 19 Feb 2015 00:32:00 +0800
parents 02baa0b334e8
children 5ad81aa19c2d ea4676b840ef
comparison
equal deleted inserted replaced
1026:59a1146e8b9d 1027:daf21fd50abf
1047 1047
1048 ses.maxfd = MAX(ses.maxfd, c->sock); 1048 ses.maxfd = MAX(ses.maxfd, c->sock);
1049 setnonblocking(c->sock); 1049 setnonblocking(c->sock);
1050 1050
1051 #if defined(__linux__) && defined(TCP_DEFER_ACCEPT) 1051 #if defined(__linux__) && defined(TCP_DEFER_ACCEPT)
1052 set_piggyback_ack(sock); 1052 //set_piggyback_ack(c->sock);
1053 #endif 1053 #endif
1054 1054
1055 #ifdef PROGRESS_CONNECT_FALLBACK
1056 #if 0
1055 if (connect(c->sock, r->ai_addr, r->ai_addrlen) < 0) { 1057 if (connect(c->sock, r->ai_addr, r->ai_addrlen) < 0) {
1056 if (errno == EINPROGRESS) { 1058 if (errno == EINPROGRESS) {
1057 TRACE(("Connect in progress")) 1059 TRACE(("Connect in progress"))
1058 break; 1060 break;
1059 } else { 1061 } else {
1063 continue; 1065 continue;
1064 } 1066 }
1065 } 1067 }
1066 1068
1067 break; /* Success. Treated the same as EINPROGRESS */ 1069 break; /* Success. Treated the same as EINPROGRESS */
1068 } 1070 #endif
1071 #else
1072 {
1073 struct msghdr message = {0};
1074 int flags;
1075 int res;
1076 message.msg_name = r->ai_addr;
1077 message.msg_namelen = r->ai_addrlen;
1078
1079 if (c->writequeue) {
1080 int iovlen; /* Linux msg_iovlen is a size_t */
1081 message.msg_iov = packet_queue_to_iovec(c->writequeue, &iovlen);
1082 message.msg_iovlen = iovlen;
1083 res = sendmsg(c->sock, &message, MSG_FASTOPEN);
1084 if (res < 0 && errno == EOPNOTSUPP) {
1085 TRACE(("Fastopen not supported"));
1086 /* No kernel MSG_FASTOPEN support. Fall back below */
1087 c->writequeue = NULL;
1088 }
1089 }
1090
1091 if (!c->writequeue) {
1092 res = connect(c->sock, r->ai_addr, r->ai_addrlen);
1093 }
1094 if (res < 0 && errno != EINPROGRESS) {
1095 err = errno;
1096 close(c->sock);
1097 c->sock = -1;
1098 continue;
1099 } else {
1100 break;
1101 }
1102 }
1103 #endif
1104 }
1105
1069 1106
1070 if (r) { 1107 if (r) {
1071 c->res_iter = r->ai_next; 1108 c->res_iter = r->ai_next;
1072 } else { 1109 } else {
1073 c->res_iter = NULL; 1110 c->res_iter = NULL;
1127 TRACE(("Error resolving: %s", gai_strerror(err))) 1164 TRACE(("Error resolving: %s", gai_strerror(err)))
1128 return NULL; 1165 return NULL;
1129 } 1166 }
1130 1167
1131 c->res_iter = c->res; 1168 c->res_iter = c->res;
1132
1133 /* Set one going */
1134 connect_try_next(c);
1135 1169
1136 return c; 1170 return c;
1137 } 1171 }
1138 1172
1139 1173
1200 return; 1234 return;
1201 } 1235 }
1202 } 1236 }
1203 TRACE(("leave handle_connect_fds - end iter")) 1237 TRACE(("leave handle_connect_fds - end iter"))
1204 } 1238 }
1239
1240 void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue *writequeue) {
1241 c->writequeue = writequeue;
1242 }