forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit105024a
committed
Improve the granularity of PQsocketPoll's timeout parameter.
Commitf5e4ded exposed libpq's internal function PQsocketPollwithout a lot of thought about whether that was an API we reallywanted to chisel in stone. The main problem with it is the use oftime_t to specify the timeout. While we do want an absolute timeso that a loop around PQsocketPoll doesn't have problems withtimeout slippage, time_t has only 1-second resolution. That'salready problematic for libpq's own internal usage --- for example,pqConnectDBComplete has long had a kluge to treat "connect_timeout=1"as 2 seconds so that it doesn't accidentally round to nearly zero.And it's even less likely to be satisfactory for external callers.Hence, let's change this while we still can.The best idea seems to be to use an int64 count of microseconds sincethe epoch --- basically the same thing as the backend's TimestampTz,but let's use the standard Unix epoch (1970-01-01) since that's morelikely for clients to be easy to calculate. Millisecond resolutionwould be plenty for foreseeable uses, but maybe the day will come thatwe're glad we used microseconds.Also, since time(2) isn't especially helpful for computing timeoutsdefined this way, introduce a new function PQgetCurrentTimeUSecto get the current time in this form.Remove the hack in pqConnectDBComplete, so that "connect_timeout=1"now means what you'd expect.We can also remove the "#include <time.h>" thatf5e4ded added tolibpq-fe.h, since there's no longer a need for time_t in that header.It seems better for v17 not to enlarge libpq-fe.h's include footprintfrom what it's historically been, anyway.I also failed to resist the temptation to do some wordsmithingon PQsocketPoll's documentation.Patch by me, per complaint from Dominique Devienne.Discussion:https://postgr.es/m/913559.1718055575@sss.pgh.pa.us1 parent6dfac24 commit105024a
File tree
8 files changed
+153
-78
lines changed- doc/src/sgml
- src
- bin/psql
- interfaces/libpq
- tools/pgindent
8 files changed
+153
-78
lines changedLines changed: 84 additions & 37 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
262 | 262 |
| |
263 | 263 |
| |
264 | 264 |
| |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 |
| - | |
269 |
| - | |
270 |
| - | |
271 |
| - | |
272 |
| - | |
273 |
| - | |
274 |
| - | |
275 |
| - | |
276 |
| - | |
277 |
| - | |
278 |
| - | |
279 |
| - | |
280 |
| - | |
281 |
| - | |
282 |
| - | |
283 |
| - | |
284 |
| - | |
285 |
| - | |
286 |
| - | |
287 |
| - | |
288 |
| - | |
289 |
| - | |
290 |
| - | |
291 |
| - | |
292 |
| - | |
293 |
| - | |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 | 265 |
| |
301 | 266 |
| |
302 | 267 |
| |
| |||
546 | 511 |
| |
547 | 512 |
| |
548 | 513 |
| |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
549 | 578 |
| |
550 | 579 |
| |
551 | 580 |
| |
| |||
1390 | 1419 |
| |
1391 | 1420 |
| |
1392 | 1421 |
| |
1393 |
| - | |
1394 |
| - | |
| 1422 | + | |
1395 | 1423 |
| |
1396 | 1424 |
| |
1397 | 1425 |
| |
| |||
8039 | 8067 |
| |
8040 | 8068 |
| |
8041 | 8069 |
| |
| 8070 | + | |
| 8071 | + | |
| 8072 | + | |
| 8073 | + | |
| 8074 | + | |
| 8075 | + | |
| 8076 | + | |
| 8077 | + | |
| 8078 | + | |
| 8079 | + | |
| 8080 | + | |
| 8081 | + | |
| 8082 | + | |
| 8083 | + | |
| 8084 | + | |
| 8085 | + | |
| 8086 | + | |
| 8087 | + | |
| 8088 | + | |
8042 | 8089 |
| |
8043 | 8090 |
| |
8044 | 8091 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3764 | 3764 |
| |
3765 | 3765 |
| |
3766 | 3766 |
| |
3767 |
| - | |
| 3767 | + | |
3768 | 3768 |
| |
3769 | 3769 |
| |
3770 | 3770 |
| |
| |||
3795 | 3795 |
| |
3796 | 3796 |
| |
3797 | 3797 |
| |
3798 |
| - | |
| 3798 | + | |
3799 | 3799 |
| |
3800 | 3800 |
| |
3801 | 3801 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
204 | 204 |
| |
205 | 205 |
| |
206 | 206 |
| |
| 207 | + |
Lines changed: 5 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2470 | 2470 |
| |
2471 | 2471 |
| |
2472 | 2472 |
| |
2473 |
| - | |
| 2473 | + | |
2474 | 2474 |
| |
2475 | 2475 |
| |
2476 | 2476 |
| |
| |||
2479 | 2479 |
| |
2480 | 2480 |
| |
2481 | 2481 |
| |
2482 |
| - | |
| 2482 | + | |
2483 | 2483 |
| |
2484 | 2484 |
| |
2485 | 2485 |
| |
| |||
2490 | 2490 |
| |
2491 | 2491 |
| |
2492 | 2492 |
| |
2493 |
| - | |
2494 |
| - | |
2495 |
| - | |
2496 |
| - | |
2497 |
| - | |
2498 |
| - | |
2499 |
| - | |
2500 |
| - | |
2501 |
| - | |
2502 |
| - | |
2503 |
| - | |
2504 |
| - | |
2505 |
| - | |
2506 | 2493 |
| |
2507 | 2494 |
| |
2508 | 2495 |
| |
| |||
2519 | 2506 |
| |
2520 | 2507 |
| |
2521 | 2508 |
| |
2522 |
| - | |
| 2509 | + | |
2523 | 2510 |
| |
2524 | 2511 |
| |
2525 | 2512 |
| |
| |||
2534 | 2521 |
| |
2535 | 2522 |
| |
2536 | 2523 |
| |
2537 |
| - | |
| 2524 | + | |
2538 | 2525 |
| |
2539 | 2526 |
| |
2540 | 2527 |
| |
| |||
2544 | 2531 |
| |
2545 | 2532 |
| |
2546 | 2533 |
| |
2547 |
| - | |
| 2534 | + | |
2548 | 2535 |
| |
2549 | 2536 |
| |
2550 | 2537 |
| |
|
Lines changed: 51 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
57 |
| - | |
| 57 | + | |
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
| |||
977 | 977 |
| |
978 | 978 |
| |
979 | 979 |
| |
980 |
| - | |
| 980 | + | |
981 | 981 |
| |
982 | 982 |
| |
983 | 983 |
| |
984 |
| - | |
985 |
| - | |
986 |
| - | |
| 984 | + | |
987 | 985 |
| |
988 | 986 |
| |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
989 | 992 |
| |
990 | 993 |
| |
991 |
| - | |
| 994 | + | |
992 | 995 |
| |
993 | 996 |
| |
994 | 997 |
| |
995 |
| - | |
| 998 | + | |
996 | 999 |
| |
997 | 1000 |
| |
998 | 1001 |
| |
| |||
1013 | 1016 |
| |
1014 | 1017 |
| |
1015 | 1018 |
| |
1016 |
| - | |
| 1019 | + | |
1017 | 1020 |
| |
1018 | 1021 |
| |
1019 | 1022 |
| |
| |||
1023 | 1026 |
| |
1024 | 1027 |
| |
1025 | 1028 |
| |
1026 |
| - | |
| 1029 | + | |
1027 | 1030 |
| |
1028 | 1031 |
| |
1029 | 1032 |
| |
| |||
1035 | 1038 |
| |
1036 | 1039 |
| |
1037 | 1040 |
| |
1038 |
| - | |
| 1041 | + | |
1039 | 1042 |
| |
1040 | 1043 |
| |
1041 | 1044 |
| |
| |||
1079 | 1082 |
| |
1080 | 1083 |
| |
1081 | 1084 |
| |
| 1085 | + | |
| 1086 | + | |
1082 | 1087 |
| |
1083 | 1088 |
| |
1084 | 1089 |
| |
1085 | 1090 |
| |
1086 |
| - | |
| 1091 | + | |
1087 | 1092 |
| |
1088 | 1093 |
| |
1089 | 1094 |
| |
| |||
1103 | 1108 |
| |
1104 | 1109 |
| |
1105 | 1110 |
| |
1106 |
| - | |
| 1111 | + | |
1107 | 1112 |
| |
| 1113 | + | |
| 1114 | + | |
1108 | 1115 |
| |
1109 | 1116 |
| |
1110 |
| - | |
| 1117 | + | |
1111 | 1118 |
| |
1112 | 1119 |
| |
1113 |
| - | |
| 1120 | + | |
1114 | 1121 |
| |
1115 | 1122 |
| |
1116 | 1123 |
| |
| |||
1138 | 1145 |
| |
1139 | 1146 |
| |
1140 | 1147 |
| |
1141 |
| - | |
| 1148 | + | |
1142 | 1149 |
| |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
1143 | 1156 |
| |
1144 | 1157 |
| |
1145 |
| - | |
| 1158 | + | |
1146 | 1159 |
| |
1147 | 1160 |
| |
1148 |
| - | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1149 | 1165 |
| |
| 1166 | + | |
1150 | 1167 |
| |
1151 |
| - | |
| 1168 | + | |
| 1169 | + | |
1152 | 1170 |
| |
1153 | 1171 |
| |
1154 | 1172 |
| |
| |||
1157 | 1175 |
| |
1158 | 1176 |
| |
1159 | 1177 |
| |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1160 | 1193 |
| |
1161 | 1194 |
| |
1162 | 1195 |
| |
|
0 commit comments
Comments
(0)