returns 1 on successful lock, 0 on unsuccessful lock, -1 on error */
| 211 | |
| 212 | /* returns 1 on successful lock, 0 on unsuccessful lock, -1 on error */ |
| 213 | static int lock(int fd, int type) |
| 214 | { |
| 215 | int ret; |
| 216 | |
| 217 | /* flock may be interrupted */ |
| 218 | do { |
| 219 | ret = flock(fd, type | LOCK_NB); |
| 220 | } while (ret && errno == EINTR); |
| 221 | |
| 222 | if (ret && errno == EWOULDBLOCK) { |
| 223 | /* couldn't lock */ |
| 224 | return 0; |
| 225 | } else if (ret) { |
| 226 | RTE_LOG(ERR, EAL, "%s(): error calling flock(): %s\n", |
| 227 | __func__, strerror(errno)); |
| 228 | return -1; |
| 229 | } |
| 230 | /* lock was successful */ |
| 231 | return 1; |
| 232 | } |
| 233 | |
| 234 | static int |
| 235 | get_seg_memfd(struct hugepage_info *hi __rte_unused, |
no test coverage detected