+ while (v2_socket.sock < 0) {
+ /* bail out on unexpected error, or suffix wrap-around */
+ if (v2_socket.sock != -EADDRINUSE || suffix < 0) {
+ v2_socket.path[0] = '\0'; /* clear socket path */
+ return -1;
+ }
+ /* add a suffix to the path if the basic version fails */
+ if (snprintf(v2_socket.path, sizeof(v2_socket.path), "%s:%d",
+ spath, ++suffix) >= (int)sizeof(v2_socket.path)) {
+ TMTY_LOG(ERR, "Error with socket binding, path too long\n");
+ return -1;
+ }
+ v2_socket.sock = create_socket(v2_socket.path);
+ }