workqueue: cond_resched() after processing each work item
[firefly-linux-kernel-4.4.55.git] / ipc / msg.c
index d0c6d967b390a888b913812d772db2c9bf366810..f8fbe2c095ceb5eda82fbaefcda6832e35621844 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -795,7 +795,7 @@ static inline void free_copy(struct msg_msg *copy)
 
 static struct msg_msg *find_msg(struct msg_queue *msq, long *msgtyp, int mode)
 {
-       struct msg_msg *msg;
+       struct msg_msg *msg, *found = NULL;
        long count = 0;
 
        list_for_each_entry(msg, &msq->q_messages, m_list) {
@@ -804,6 +804,7 @@ static struct msg_msg *find_msg(struct msg_queue *msq, long *msgtyp, int mode)
                                               *msgtyp, mode)) {
                        if (mode == SEARCH_LESSEQUAL && msg->m_type != 1) {
                                *msgtyp = msg->m_type - 1;
+                               found = msg;
                        } else if (mode == SEARCH_NUMBER) {
                                if (*msgtyp == count)
                                        return msg;
@@ -813,7 +814,7 @@ static struct msg_msg *find_msg(struct msg_queue *msq, long *msgtyp, int mode)
                }
        }
 
-       return ERR_PTR(-EAGAIN);
+       return found ?: ERR_PTR(-EAGAIN);
 }