|
@@ -159,6 +159,27 @@ static void dso__list_del(struct dso *dso)
|
|
|
dso__data_open_cnt--;
|
|
|
}
|
|
|
|
|
|
+static void close_first_dso(void);
|
|
|
+
|
|
|
+static int do_open(char *name)
|
|
|
+{
|
|
|
+ int fd;
|
|
|
+
|
|
|
+ do {
|
|
|
+ fd = open(name, O_RDONLY);
|
|
|
+ if (fd >= 0)
|
|
|
+ return fd;
|
|
|
+
|
|
|
+ pr_debug("dso open failed, mmap: %s\n", strerror(errno));
|
|
|
+ if (!dso__data_open_cnt || errno != EMFILE)
|
|
|
+ break;
|
|
|
+
|
|
|
+ close_first_dso();
|
|
|
+ } while (1);
|
|
|
+
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
static int __open_dso(struct dso *dso, struct machine *machine)
|
|
|
{
|
|
|
int fd;
|
|
@@ -177,7 +198,7 @@ static int __open_dso(struct dso *dso, struct machine *machine)
|
|
|
return -EINVAL;
|
|
|
}
|
|
|
|
|
|
- fd = open(name, O_RDONLY);
|
|
|
+ fd = do_open(name);
|
|
|
free(name);
|
|
|
return fd;
|
|
|
}
|