MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / connTLSSyncReadLine

Function connTLSSyncReadLine

src/tls.cpp:1230–1260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1228}
1229
1230static ssize_t connTLSSyncReadLine(connection *conn_, char *ptr, ssize_t size, long long timeout) {
1231 tls_connection *conn = (tls_connection *) conn_;
1232 ssize_t nread = 0;
1233
1234 serverAssert(conn->el == serverTL->el);
1235
1236 setBlockingTimeout(conn, timeout);
1237
1238 size--;
1239 while(size) {
1240 char c;
1241
1242 if (SSL_read(conn->ssl,&c,1) <= 0) {
1243 nread = -1;
1244 goto exit;
1245 }
1246 if (c == '\n') {
1247 *ptr = '\0';
1248 if (nread && *(ptr-1) == '\r') *(ptr-1) = '\0';
1249 goto exit;
1250 } else {
1251 *ptr++ = c;
1252 *ptr = '\0';
1253 nread++;
1254 }
1255 size--;
1256 }
1257exit:
1258 unsetBlockingTimeout(conn);
1259 return nread;
1260}
1261
1262static int connTLSGetType(connection *conn_) {
1263 (void) conn_;

Callers

nothing calls this directly

Calls 2

setBlockingTimeoutFunction · 0.85
unsetBlockingTimeoutFunction · 0.85

Tested by

no test coverage detected